Quantcast
Channel: Latest Questions by zenforhire
Viewing all articles
Browse latest Browse all 83

data shared between scenes cannot be used in inspector?

$
0
0
I'm use to binding/drag and drop my Model data to my Views in the inspector. For game state data you can't since the common solution to a Singleton is new GameObject() at runtime. public class MyClass : MonoBehaviour { static MyClass mInstance; public static MyClass Instance { get { if (mInstance == null){ GameObject go = new GameObject(); mInstance = go.AddComponent(); } return mInstance; } } } So i have to write code to connect the model to the view? GUI code left out. I would have made alarmClock public so I could drag and drop normally. class AlarmClockView : MonoBehavior { private AlarmClockModel alarmClock; void Start() { alarmClock = GameState.getInstance().alarmClockModel; } Thanks

Viewing all articles
Browse latest Browse all 83

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>