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<MyClass>();
}
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