示例#1
0
    public static void Start()
    {
        var sceneCount = SceneManager.sceneCount;

        for (var sceneIndex = 0; sceneIndex < sceneCount; sceneIndex++)
        {
            var scene           = SceneManager.GetSceneAt(sceneIndex);
            var rootGameObjects = scene.GetRootGameObjects();

            // Attach an EgoComponent Component to every GameObject in the scene
            foreach (var go in rootGameObjects)
            {
                InitEgoComponent(go);
            }

            // Add every GameObject to any relevant system
            foreach (var system in _systems)
            {
                foreach (var go in rootGameObjects)
                {
                    var egoComponent = go.GetComponent <EgoComponent>();
                    system.CreateBundles(egoComponent);
                }
            }
        }

        EgoEvents.Start();

        // Start all Systems
        foreach (var system in _systems)
        {
            system.Start();
        }

        // Invoke all queued Events
        EgoEvents.Invoke();

        // Clean up Destroyed Components & GameObjects
        EgoCleanUp.CleanUp();
    }