コード例 #1
0
    protected override void Awake()
    {
        base.Awake();
        gameRunning.onLockStateChange += GameRunning_onLockStateChange;

        PersistentLoader.LoadIfNotLoaded(InitGame);
    }
コード例 #2
0
 void Start()
 {
     if (loadOnStart)
     {
         PersistentLoader.LoadIfNotLoaded(Load);
     }
     else
     {
         PersistentLoader.LoadIfNotLoaded();
     }
 }
コード例 #3
0
 private void Awake()
 {
     if (Instance == null)              //If there are no other instances of this object
     {
         Instance = this;               //Set this to the Instance
         DontDestroyOnLoad(gameObject); //Don't destroy
     }
     else //If there ARE other instances of this object
     {
         Destroy(gameObject); //Destroy them
     }
 }
コード例 #4
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        queue = new InitQueue(() =>
        {
            //On complete
            for (int i = 0; i < callbacks.Count; i++)
            {
                callbacks[i]();
            }
            callbacks = null;
        });

        for (int i = 0; i < persistentObjects.Count; i++)
        {
            if (persistentObjects[i] == null)
            {
                continue;
            }

            IPersistent manager = persistentObjects[i] as IPersistent;
            if (manager != null)
            {
                persistentObjects[i] = manager.DuplicationBehavior();
                manager = persistentObjects[i] as IPersistent;

                //Init
                manager.Init(queue.Register());
            }
        }
        queue.MarkEnd();
    }
コード例 #5
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        queue = new InitQueue(() =>
        {
            //On complete
            for (int i = 0; i < callbacks.Count; i++)
            {
                callbacks[i]();
            }
            callbacks = null;
        });

        for (int i = 0; i < persistentObjects.Count; i++)
        {
            if (persistentObjects[i] == null)
            {
                continue;
            }

            IPersistent manager = persistentObjects[i] as IPersistent;
            if (manager != null)
            {
                string name = persistentObjects[i].name;
                pendingObjects.Add(name);

                persistentObjects[i] = manager.DuplicationBehavior();
                manager = persistentObjects[i] as IPersistent;

                Action registeration = queue.Register();

                //Init
                manager.Init(() =>
                {
                    pendingObjects.Remove(name);
                    registeration();
                });
            }
        }
        queue.MarkEnd();

        this.DelayedCall(() =>
        {
            if (!queue.IsOver)
            {
                Debug.Log("A manager is taking an abnormally long time to initialize.");
                for (int i = 0; i < pendingObjects.Count; i++)
                {
                    Debug.Log(pendingObjects[i] + " has not called 'onComplete' yet.");
                }
            }
        }, 2);
    }
コード例 #6
0
 private void Awake()
 {
     PersistentLoader.LoadIfNotLoaded();
 }