Example #1
0
        private void preprocess()          // do action && update families
        //
        // The way we are dequeuing the actions allows trick with On**** unity callback
        // and Actions.perform function.
        // ->
        // If we add an action with FYFY functions in OnDestroy unity callback, this new
        // action is added to the queue and will be treated during the same dequeue loop
        // of the remove action at the origin of the OnDestroy calling.
        // Same principle inside Actions.perform function.
        //
        {
            while (GameObjectManager._delayedActions.Count != 0)
            {
                // During the action perform (and so the Unity callbacks), the current action is always present on the queue top.
                // This is used in TriggerManager && CollisionManager dlls.
                try{
                    GameObjectManager._delayedActions.Peek().perform();
                } catch (System.Exception e) {
                    UnityEngine.Debug.LogException(e);
                }
                GameObjectManager._delayedActions.Dequeue();
            }

            foreach (int gameObjectId in GameObjectManager._unbindedGameObjectIds)
            {
                FamilyManager.updateAfterGameObjectUnbinded(gameObjectId);
                GameObjectManager._modifiedGameObjectIds.Remove(gameObjectId);
            }
            GameObjectManager._unbindedGameObjectIds.Clear();

            foreach (int gameObjectId in GameObjectManager._modifiedGameObjectIds)
            {
                FamilyManager.updateAfterGameObjectModified(gameObjectId);
            }
            GameObjectManager._modifiedGameObjectIds.Clear();

            ++_familiesUpdateCount;
        }
Example #2
0
        private void preprocess()          // do action && update families
        //
        // The way we are dequeuing the actions allows trick with On**** unity callback
        // and Actions.perform function.
        // ->
        // If we add an action with FYFY functions in OnDestroy unity callback, this new
        // action is added to the queue and will be treated during the same dequeue loop
        // of the remove action at the origin of the OnDestroy calling.
        // Same principle inside Actions.perform function.
        //

        // Load scenes
        {
            if (lastFrameSceneLoaded != -1 && lastFrameSceneLoaded == Time.frameCount - 1)
            {
                foreach (int sceneId in loadedSceneById)
                {
                    GameObject[] roots = SceneManager.GetSceneByBuildIndex(sceneId).GetRootGameObjects();
                    foreach (GameObject root in roots)
                    {
                        GameObjectManager.bind(root);
                    }
                }
                foreach (string sceneName in loadedSceneByName)
                {
                    GameObject[] roots = SceneManager.GetSceneByName(sceneName).GetRootGameObjects();
                    foreach (GameObject root in roots)
                    {
                        GameObjectManager.bind(root);
                    }
                }
                loadedSceneById.Clear();
                loadedSceneByName.Clear();
                lastFrameSceneLoaded = -1;
            }

            while (GameObjectManager._delayedActions.Count != 0)
            {
                // During the action perform (and so the Unity callbacks), the current action is always present on the queue top.
                // This is used in TriggerManager && CollisionManager dlls.
                try{
                    GameObjectManager._delayedActions.Peek().perform();
                } catch (System.Exception e) {
                    UnityEngine.Debug.LogException(e);
                }
                GameObjectManager._delayedActions.Dequeue();
            }

            foreach (int gameObjectId in GameObjectManager._unbindedGameObjectIds)
            {
                FamilyManager.updateAfterGameObjectUnbinded(gameObjectId);
                GameObjectManager._modifiedGameObjectIds.Remove(gameObjectId);
            }
            GameObjectManager._unbindedGameObjectIds.Clear();

            // Working on a copy to avoid collection was modified during enumeration
            HashSet <int> copy = new HashSet <int>(GameObjectManager._modifiedGameObjectIds);

            foreach (int gameObjectId in copy)
            {
                FamilyManager.updateAfterGameObjectModified(gameObjectId);
            }
            GameObjectManager._modifiedGameObjectIds.Clear();

            ++_familiesUpdateCount;
        }