public override void OnInspectorGUI()
        {
            var subScene = target as SubScene;

            var prevSceneAsset = subScene.SceneAsset;
            var prevColor      = subScene.HierarchyColor;

            base.OnInspectorGUI();

            if (subScene.SceneAsset != prevSceneAsset || subScene.HierarchyColor != prevColor)
            {
                SceneHierarchyHooks.ReloadAllSceneHierarchies();
            }

            var targetsArray = targets;
            var subscenes    = new SubScene[targetsArray.Length];

            targetsArray.CopyTo(subscenes, 0);


            EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);

            GUILayout.BeginHorizontal();
            if (!SubSceneInspectorUtility.IsEditingAll(subscenes))
            {
                GUI.enabled = SubSceneInspectorUtility.CanEditScene(subscenes);
                if (GUILayout.Button("Edit"))
                {
                    SubSceneInspectorUtility.EditScene(subscenes);
                }
            }
            else
            {
                GUI.enabled = true;
                if (GUILayout.Button("Close"))
                {
                    SubSceneInspectorUtility.CloseAndAskSaveIfUserWantsTo(subscenes);
                }
            }


            GUI.enabled = SubSceneInspectorUtility.IsDirty(subscenes);
            if (GUILayout.Button("Save"))
            {
                SubSceneInspectorUtility.SaveScene(subscenes);
            }
            GUI.enabled = true;

            GUILayout.EndHorizontal();

            var scenes = SubSceneInspectorUtility.GetLoadableScenes(subscenes);

            EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);

            GUILayout.Space(10);

            if (World.DefaultGameObjectInjectionWorld != null)
            {
                var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

                foreach (var scene in scenes)
                {
                    if (!entityManager.HasComponent <RequestSceneLoaded>(scene.Scene))
                    {
                        if (GUILayout.Button($"Load '{scene.Name}'"))
                        {
                            entityManager.AddComponentData(scene.Scene, new RequestSceneLoaded());
                            EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
                        }
                    }
                    else
                    {
                        if (GUILayout.Button($"Unload '{scene.Name}'"))
                        {
                            entityManager.RemoveComponent <RequestSceneLoaded>(scene.Scene);
                            EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
                        }
                    }
                }
            }


    #if false
            // @TODO: TEMP for debugging
            if (GUILayout.Button("ClearWorld"))
            {
                World.DisposeAllWorlds();
                DefaultWorldInitialization.Initialize("Default World", !Application.isPlaying);

                var scenes = FindObjectsOfType <SubScene>();
                foreach (var scene in scenes)
                {
                    var oldEnabled = scene.enabled;
                    scene.enabled = false;
                    scene.enabled = oldEnabled;
                }

                EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
            }
    #endif

            var uncleanHierarchyObject = SubSceneInspectorUtility.GetUncleanHierarchyObject(subscenes);
            if (uncleanHierarchyObject != null)
            {
                EditorGUILayout.HelpBox($"Scene transform values are not applied to scenes child transforms. But {uncleanHierarchyObject.name} has an offset Transform.", MessageType.Warning, true);
                if (GUILayout.Button("Clear"))
                {
                    foreach (var scene in subscenes)
                    {
                        scene.transform.localPosition = Vector3.zero;
                        scene.transform.localRotation = Quaternion.identity;
                        scene.transform.localScale    = Vector3.one;
                    }
                }
            }
            if (SubSceneInspectorUtility.HasChildren(subscenes))
            {
                EditorGUILayout.HelpBox($"SubScenes can not have child game objects. Close the scene and delete the child game objects.", MessageType.Warning, true);
            }

            if (CheckConversionLog(subScene))
            {
                GUILayout.Space(10);
                GUILayout.Label("Importing...");
                Repaint();
            }
            if (m_ConversionLog.Length != 0)
            {
                GUILayout.Space(10);

                GUILayout.Label("Conversion Log");
                GUILayout.TextArea(m_ConversionLog);
            }
        }
Example #2
0
        public bool Initialize(string defaultWorldName)
        {
            var world = new World(defaultWorldName);

            this.EntityManager = world.EntityManager;

            var map         = Map.NewMapRoomsAndCorridors(this.EntityManager);
            var rooms       = map.Rooms;
            var roomCenters = new NativeArray <int2>(rooms.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);

            for (int i = 0; i < rooms.Length; i++)
            {
                var(x, y)      = rooms[i].Center();
                roomCenters[i] = int2(x, y);
            }

            this.CreatePlayer(roomCenters[0]);

            var rng = RandomNumberGenerator.New();

            for (int i = 1; i < roomCenters.Length; i++)
            {
                byte   glyph;
                string name;

                var roll = rng.RollDice(1, 2);

                switch (roll)
                {
                case 1:
                    glyph = (byte)'g';
                    name  = "Goblin";
                    break;

                default:
                    glyph = (byte)'o';
                    name  = "Orc";
                    break;
                }

                var monster =
                    this.EntityManager.CreateEntity(
                        typeof(Position),
                        typeof(Renderable),
                        typeof(VisibleTilePosition),
                        typeof(ViewshedData),
                        typeof(Monster),
                        typeof(Name),
                        typeof(BlocksTile),
                        typeof(CombatStats));
                var formattedName = $"{name} #{i}";
                this.EntityManager.SetName(monster, formattedName);
                this.EntityManager.SetComponentData(monster, new Position {
                    Value = roomCenters[i]
                });
                this.EntityManager.SetComponentData(
                    monster,
                    new Renderable {
                    Glyph = glyph, Foreground = Color.red, Background = Color.black
                });
                this.EntityManager.SetComponentData(monster, new ViewshedData {
                    Range = 8
                });
                this.EntityManager.SetComponentData(monster, new Name {
                    Value = formattedName
                });
                this.EntityManager.SetComponentData(monster, new CombatStats {
                    MaxHP = 16, HP = 16, Defense = 2, Power = 5
                });
            }


            World.DefaultGameObjectInjectionWorld = world;
            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, systems);
            ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world);

            return(true);
        }
        public override void OnInspectorGUI()
        {
            var subScene = target as SubScene;

            if (!subScene.IsInMainStage())
            {
                // In Prefab Mode and when selecting a Prefab Asset in the Project Browser we only show the inspector of data of the
                // SubScene, and not the load/unload/edit/close buttons.
                base.OnInspectorGUI();

                EditorGUILayout.HelpBox($"Only Sub Scenes in the Main Stage can be loaded and unloaded.", MessageType.Info, true);
                EditorGUILayout.Space();
                return;
            }

            var prevColor = subScene.HierarchyColor;

            CachePreviousSceneAssetReferences();

            base.OnInspectorGUI();

            HandleChangedSceneAssetReferences();

            if (subScene.HierarchyColor != prevColor)
            {
                SceneHierarchyHooks.ReloadAllSceneHierarchies();
            }

            var targetsArray = targets;
            var subscenes    = new SubScene[targetsArray.Length];

            targetsArray.CopyTo(subscenes, 0);

            GUILayout.BeginHorizontal();
            if (!SubSceneInspectorUtility.IsEditingAll(subscenes))
            {
                GUI.enabled = SubSceneInspectorUtility.CanEditScene(subscenes);
                if (GUILayout.Button("Edit"))
                {
                    SubSceneInspectorUtility.EditScene(subscenes);
                }
            }
            else
            {
                GUI.enabled = true;
                if (GUILayout.Button("Close"))
                {
                    SubSceneInspectorUtility.CloseAndAskSaveIfUserWantsTo(subscenes);
                }
            }

            GUI.enabled = SubSceneInspectorUtility.IsDirty(subscenes);
            if (GUILayout.Button("Save"))
            {
                SubSceneInspectorUtility.SaveScene(subscenes);
            }
            GUI.enabled = true;

            GUILayout.EndHorizontal();

            var scenes = SubSceneInspectorUtility.GetLoadableScenes(subscenes);

            GUILayout.Space(10);

            if (World.DefaultGameObjectInjectionWorld != null)
            {
                var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

                foreach (var scene in scenes)
                {
                    if (!entityManager.HasComponent <RequestSceneLoaded>(scene.Scene))
                    {
                        if (GUILayout.Button($"Load '{scene.Name}'"))
                        {
                            entityManager.AddComponentData(scene.Scene, new RequestSceneLoaded());
                            EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
                        }
                    }
                    else
                    {
                        if (GUILayout.Button($"Unload '{scene.Name}'"))
                        {
                            entityManager.RemoveComponent <RequestSceneLoaded>(scene.Scene);
                            EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
                        }
                    }
                }
            }

    #if false
            // @TODO: TEMP for debugging
            if (GUILayout.Button("ClearWorld"))
            {
                World.DisposeAllWorlds();
                DefaultWorldInitialization.Initialize("Default World", !Application.isPlaying);

                var scenes = FindObjectsOfType <SubScene>();
                foreach (var scene in scenes)
                {
                    var oldEnabled = scene.enabled;
                    scene.enabled = false;
                    scene.enabled = oldEnabled;
                }

                EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
            }
    #endif

            bool hasDuplicates = subScene.SceneAsset != null && (SubScene.AllSubScenes.Count(s => (s.SceneAsset == subScene.SceneAsset)) > 1);
            if (hasDuplicates)
            {
                EditorGUILayout.HelpBox($"The Scene Asset '{subScene.EditableScenePath}' is used mutiple times and this is not supported. Clear the reference.", MessageType.Warning, true);
                if (GUILayout.Button("Clear"))
                {
                    subScene.SceneAsset = null;
                    SceneHierarchyHooks.ReloadAllSceneHierarchies();
                }
                EditorGUILayout.Space();
            }

            var uncleanHierarchyObject = SubSceneInspectorUtility.GetUncleanHierarchyObject(subscenes);
            if (uncleanHierarchyObject != null)
            {
                EditorGUILayout.HelpBox($"Scene transform values are not applied to scenes child transforms. But {uncleanHierarchyObject.name} has an offset Transform.", MessageType.Warning, true);
                if (GUILayout.Button("Clear"))
                {
                    foreach (var scene in subscenes)
                    {
                        scene.transform.localPosition = Vector3.zero;
                        scene.transform.localRotation = Quaternion.identity;
                        scene.transform.localScale    = Vector3.one;
                    }
                }
                EditorGUILayout.Space();
            }
            if (SubSceneInspectorUtility.HasChildren(subscenes))
            {
                EditorGUILayout.HelpBox($"SubScenes can not have child game objects. Close the scene and delete the child game objects.", MessageType.Warning, true);
            }

            if (CheckConversionLog(subScene))
            {
                GUILayout.Space(10);
                GUILayout.Label("Importing...");
                Repaint();
            }
            if (m_ConversionLog.Length != 0)
            {
                GUILayout.Space(10);

                GUILayout.Label("Conversion Log");
                GUILayout.TextArea(m_ConversionLog);
            }
        }
 private void Start()
 {
     DefaultWorldInitialization.Initialize("Default World");
     SceneManager.LoadScene(1);
 }
Example #5
0
 void DoBootstrap()
 {
     DefaultWorldInitialization.Initialize("Server World", false);
     DefaultWorldInitialization.Initialize("Client World", false);
 }
 static void InitializeBeforeSceneLoad()
 {
     DefaultWorldInitialization.Initialize("My Own World", false);
 }
        public void Initialize_ShouldLogNothing()
        {
            DefaultWorldInitialization.Initialize("Test World", true);

            LogAssert.NoUnexpectedReceived();
        }
Example #8
0
 public static IEnumerable <Type> GetDefaultInitSystemsFromEntitiesPackage(WorldSystemFilterFlags flags) => FilterSystemsToPackages(
     DefaultWorldInitialization.GetAllSystems(flags), EntitiesPackage
     );
Example #9
0
 private void OnDisable()
 {
     World.DisposeAllWorlds();
     DefaultWorldInitialization.Initialize("Default World", !Application.isPlaying);
 }
Example #10
0
        public bool Initialize(string defaultWorldName)
        {
            // Initialize the world normally
            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

            var world = new World(defaultWorldName);

            World.DefaultGameObjectInjectionWorld = world;

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, systems);
            ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world);

            // Moving SimulationSystemGroup to FixedUpdate is done in two parts.
            // The PlayerLoopSystem of type SimulationSystemGroup has to be found,
            // stored, and removed before adding it to the FixedUpdate PlayerLoopSystem.

            PlayerLoopSystem playerLoop = PlayerLoop.GetCurrentPlayerLoop();

            // simulationSystem has to be constructed or compiler will complain due to
            //    using non-assigned variables.
            PlayerLoopSystem simulationSystem = new PlayerLoopSystem();
            bool             simSysFound      = false;

            // Find the location of the SimulationSystemGroup under the Update Loop
            for (var i = 0; i < playerLoop.subSystemList.Length; ++i)
            {
                int subsystemListLength = playerLoop.subSystemList[i].subSystemList.Length;

                // Find Update loop...
                if (playerLoop.subSystemList[i].type != typeof(Update))
                {
                    continue;
                }

                // Pop out SimulationSystemGroup and store it temporarily
                var newSubsystemList = new PlayerLoopSystem[subsystemListLength - 1];
                int k = 0;

                for (var j = 0; j < subsystemListLength; ++j)
                {
                    if (playerLoop.subSystemList[i].subSystemList[j].type == typeof(SimulationSystemGroup))
                    {
                        simulationSystem = playerLoop.subSystemList[i].subSystemList[j];
                        simSysFound      = true;
                    }
                    else
                    {
                        newSubsystemList[k] = playerLoop.subSystemList[i].subSystemList[j];
                        k++;
                    }
                }

                playerLoop.subSystemList[i].subSystemList = newSubsystemList;
            }

            // This should never happen if SimulationSystemGroup was created like usual
            // (or at least I think it might not happen :P )
            if (!simSysFound)
            {
                throw new System.Exception("SimulationSystemGroup was not found!");
            }

            // Round 2: find FixedUpdate...
            for (var i = 0; i < playerLoop.subSystemList.Length; ++i)
            {
                int subsystemListLength = playerLoop.subSystemList[i].subSystemList.Length;

                // Found FixedUpdate
                if (playerLoop.subSystemList[i].type != typeof(FixedUpdate))
                {
                    continue;
                }

                // Allocate new space for stored SimulationSystemGroup
                //    PlayerLoopSystem, and place simulation group at index defined by
                //    temporary variable.
                var newSubsystemList = new PlayerLoopSystem[subsystemListLength + 1];
                int k = 0;

                int indexToPlaceSimulationSystemGroupIn = subsystemListLength;

                for (var j = 0; j < subsystemListLength + 1; ++j)
                {
                    if (j == indexToPlaceSimulationSystemGroupIn)
                    {
                        newSubsystemList[j] = simulationSystem;
                    }
                    else
                    {
                        newSubsystemList[j] = playerLoop.subSystemList[i].subSystemList[k];
                        k++;
                    }
                }

                playerLoop.subSystemList[i].subSystemList = newSubsystemList;
            }

            // Set the beautiful, new player loop
            PlayerLoop.SetPlayerLoop(playerLoop);

            return(true);
        }
        public override void OnInspectorGUI()
        {
            var subScene = target as SubScene;

            if (!subScene.IsInMainStage())
            {
                // In Prefab Mode and when selecting a Prefab Asset in the Project Browser we only show the inspector of data of the
                // SubScene, and not the load/unload/edit/close buttons.
                base.OnInspectorGUI();

                EditorGUILayout.HelpBox($"Only Sub Scenes in the Main Stage can be loaded and unloaded.", MessageType.Info, true);
                EditorGUILayout.Space();
                return;
            }

            var prevColor = subScene.HierarchyColor;

            CachePreviousSceneAssetReferences();

            base.OnInspectorGUI();

            HandleChangedSceneAssetReferences();

            if (subScene.HierarchyColor != prevColor)
            {
                SceneHierarchyHooks.ReloadAllSceneHierarchies();
            }

            DrawOpenSubScenes(_selectedSubscenes);
            var loadableScenes = SubSceneInspectorUtility.GetLoadableScenes(_selectedSubscenes);

            if (DrawClosedSubScenes(loadableScenes, _selectedSubscenes))
            {
                Repaint();
            }

#if false
            // @TODO: TEMP for debugging
            if (GUILayout.Button("ClearWorld"))
            {
                World.DisposeAllWorlds();
                DefaultWorldInitialization.Initialize("Default World", !Application.isPlaying);

                var scenes = FindObjectsOfType <SubScene>();
                foreach (var scene in scenes)
                {
                    var oldEnabled = scene.enabled;
                    scene.enabled = false;
                    scene.enabled = oldEnabled;
                }

                EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
            }
    #endif

            bool hasDuplicates = subScene.SceneAsset != null && (SubScene.AllSubScenes.Count(s => (s.SceneAsset == subScene.SceneAsset)) > 1);
            if (hasDuplicates)
            {
                EditorGUILayout.HelpBox($"The Scene Asset '{subScene.EditableScenePath}' is used mutiple times and this is not supported. Clear the reference.", MessageType.Warning, true);
                if (GUILayout.Button("Clear"))
                {
                    subScene.SceneAsset = null;
                    SceneHierarchyHooks.ReloadAllSceneHierarchies();
                }
                EditorGUILayout.Space();
            }

            var uncleanHierarchyObject = SubSceneInspectorUtility.GetUncleanHierarchyObject(_selectedSubscenes);
            if (uncleanHierarchyObject != null)
            {
                EditorGUILayout.HelpBox($"Scene transform values are not applied to scenes child transforms. But {uncleanHierarchyObject.name} has an offset Transform.", MessageType.Warning, true);
                if (GUILayout.Button("Clear"))
                {
                    foreach (var scene in _selectedSubscenes)
                    {
                        scene.transform.localPosition = Vector3.zero;
                        scene.transform.localRotation = Quaternion.identity;
                        scene.transform.localScale    = Vector3.one;
                    }
                }
                EditorGUILayout.Space();
            }
            if (SubSceneInspectorUtility.HasChildren(_selectedSubscenes))
            {
                EditorGUILayout.HelpBox($"SubScenes can not have child game objects. Close the scene and delete the child game objects.", MessageType.Warning, true);
            }

            if (targets.Length == 1)
            {
                GUILayout.Space(EditorGUIUtility.singleLineHeight);
                if (CheckConversionLog(subScene))
                {
                    GUILayout.Label("Importing...");
                    Repaint();
                }

                if (m_ConversionLog.Length != 0)
                {
                    GUILayout.Space(EditorGUIUtility.singleLineHeight);

                    GUILayout.Label("Conversion Log", EditorStyles.boldLabel);
                    GUILayout.TextArea(m_ConversionLog);
                }
            }
        }
Example #12
0
        public static void Initialize()
        {
#if UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP
            DefaultWorldInitialization.Initialize("Default World", false);
#endif
        }
 public static void LoadGameplayScene()
 {
     DefaultWorldInitialization.Initialize("Default World", false);
     SceneManager.LoadScene(SceneNameUtils.SceneNameForEnum(SceneNameUtils.Scene.Gameplay));
 }
Example #14
0
        public void UpdateSceneEntities(bool warnIfMissing = false)
        {
#if UNITY_EDITOR
            var sceneHeaderPath = EntityScenesPaths.GetLoadPath(SceneGUID, EntityScenesPaths.PathType.EntitiesHeader, -1);
            m_SubSceneHeader = AssetDatabase.LoadAssetAtPath <SubSceneHeader>(sceneHeaderPath);
#endif
            if (warnIfMissing && m_SubSceneHeader == null)
            {
#if UNITY_EDITOR
                Debug.LogWarning($"Sub-scene '{EditableScenePath}' has no valid header at '{sceneHeaderPath}'. Please rebuild the Entity Cache.", this);
#else
                Debug.LogWarning($"Sub-scene '{name}' has no valid header. Please rebuild the Entity Cache.", this);
#endif
            }


            if (_SceneEntityManager != null && _SceneEntityManager.IsCreated)
            {
                foreach (var sceneEntity in _SceneEntities)
                {
                    _SceneEntityManager.DestroyEntity(sceneEntity);
                }
            }
            _SceneEntities.Clear();
            _SceneEntityManager = null;

            DefaultWorldInitialization.DefaultLazyEditModeInitialize();
            if (World.Active != null)
            {
                _SceneEntityManager = World.Active.EntityManager;

                if (m_SubSceneHeader != null)
                {
                    for (int i = 0; i < m_SubSceneHeader.Sections.Length; ++i)
                    {
                        var sceneEntity = _SceneEntityManager.CreateEntity();
                        #if UNITY_EDITOR
                        _SceneEntityManager.SetName(sceneEntity, i == 0 ? $"Scene: {SceneName}" : $"Scene: {SceneName} ({i})");
                        #endif

                        _SceneEntities.Add(sceneEntity);
                        _SceneEntityManager.AddComponentObject(sceneEntity, this);

                        if (AutoLoadScene)
                        {
                            _SceneEntityManager.AddComponentData(sceneEntity, new RequestSceneLoaded());
                        }

                        _SceneEntityManager.AddComponentData(sceneEntity, m_SubSceneHeader.Sections[i]);
                        _SceneEntityManager.AddComponentData(sceneEntity, new SceneBoundingVolume {
                            Value = m_SubSceneHeader.Sections[i].BoundingVolume
                        });
                    }
                }
                else
                {
                    var sceneEntity = _SceneEntityManager.CreateEntity();
                    #if UNITY_EDITOR
                    _SceneEntityManager.SetName(sceneEntity, "Scene: {SceneName}");
                    #endif

                    _SceneEntities.Add(sceneEntity);
                    _SceneEntityManager.AddComponentObject(sceneEntity, this);
                }
            }
        }
Example #15
0
        public static void SetUp()
        {
            s_Assets.SetUp();

            var assetGuids = new List <GUID>();

            try
            {
                {
                    string path = s_Assets.GetNextPath(".asset");
                    AssetDatabase.CreateAsset(s_TempTexture = new Texture2D(64, 64), path);
                    s_TempTextureGuid = new GUID(AssetDatabase.AssetPathToGUID(path));
                    assetGuids.Add(s_TempTextureGuid);
                }
                {
                    string path = s_Assets.GetNextPath(".mat");
                    AssetDatabase.CreateAsset(s_TempMaterial = new Material(Shader.Find("Standard")), path);
                    s_TempMaterialGuid = new GUID(AssetDatabase.AssetPathToGUID(path));
                    assetGuids.Add(s_TempMaterialGuid);
                    s_TempMaterial.mainTexture = s_TempTexture;
                }

                var tempScenePath = s_Assets.GetNextPath(".unity");
                s_TempScene            = SubSceneTestsHelper.CreateScene(tempScenePath);
                s_SubSceneWithSections = SubSceneTestsHelper.CreateSubSceneInSceneFromObjects("SubScene", false, s_TempScene, () =>
                {
                    var go1 = new GameObject();
                    go1.AddComponent <SceneSectionComponent>().SectionIndex = 0;
                    var go2 = new GameObject();
                    go2.AddComponent <SceneSectionComponent>().SectionIndex = 2;
                    go2.AddComponent <TestComponentAuthoring>().Material    = s_TempMaterial;
                    return(new List <GameObject> {
                        go1, go2
                    });
                });

                {
                    var path = s_Assets.GetNextPath("LiveLinkBuildConfig.buildconfiguration");
                    BuildConfiguration.CreateAsset(path, config =>
                    {
                        config.SetComponent(new SceneList
                        {
                            SceneInfos = new List <SceneList.SceneInfo>
                            {
                                new SceneList.SceneInfo
                                {
                                    Scene = GlobalObjectId.GetGlobalObjectIdSlow(AssetDatabase.LoadAssetAtPath <SceneAsset>(tempScenePath))
                                }
                            }
                        });
                    });
                    s_LiveLinkBuildConfigGuid = new GUID(AssetDatabase.AssetPathToGUID(path));
                }
            }
            catch
            {
                s_Assets.TearDown();
                throw;
            }

            // This call ensures that the asset worker is already running and no test times out because we're still
            // waiting for the asset worker. Effectively this doesn't change the runtime that much since we will have
            // to wait for the import to finish in most of the tests anyway.
            GeEntitySceneArtifactHash(s_SubSceneWithSections.SceneGUID, s_LiveLinkBuildConfigGuid, ImportMode.Synchronous);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            s_TempAssetGuids = assetGuids.ToArray();
            DefaultWorldInitialization.DefaultLazyEditModeInitialize();
            s_Connection = new LiveLinkTestConnection();
            EditorSceneLiveLinkToPlayerSendSystem.instance.SetConnection(s_Connection);
            LiveLinkAssetBundleBuildSystem.instance.SetConnection(s_Connection);
        }
        public bool Initialize(string defaultWorldName)
        {
            //            Physics.autoSimulation = false;
            QualitySettings.vSyncCount = -1;

            _simpleSubmitScheduler = new SimpleEntitiesSubmissionScheduler();
            _enginesRoot           = new EnginesRoot(_simpleSubmitScheduler);
            _enginesToTick         = new FasterList <IJobifiedEngine>();

            _world = new World("Custom world");

            var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

            DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, systems);

            World.DefaultGameObjectInjectionWorld = _world;

            var copySveltoToUecsEnginesGroup = new SyncSveltoToUECSGroup();

            _world.AddSystem(copySveltoToUecsEnginesGroup);
            AddSveltoEngineToTick(copySveltoToUecsEnginesGroup);

            var tickUECSSystemsGroup = new PureUECSSystemsGroup(_world);

            AddSveltoEngineToTick(tickUECSSystemsGroup);

            ///Svelto will tick the UECS engines, We need control over everything
            //ScriptBehaviourUpdateOrder.UpdatePlayerLoop(_world);

            //add the engines we are going to use
            var generateEntityFactory = _enginesRoot.GenerateEntityFactory();

            var redfoodEntity =
                GameObjectConversionUtility.ConvertGameObjectHierarchy(Resources.Load("Sphere") as GameObject,
                                                                       new GameObjectConversionSettings()
            {
                DestinationWorld = _world
            });
            var bluefoodEntity =
                GameObjectConversionUtility.ConvertGameObjectHierarchy(Resources.Load("Sphereblue") as GameObject,
                                                                       new GameObjectConversionSettings()
            {
                DestinationWorld = _world
            });
            var redDoofusEntity =
                GameObjectConversionUtility.ConvertGameObjectHierarchy(Resources.Load("RedCapsule") as GameObject,
                                                                       new GameObjectConversionSettings()
            {
                DestinationWorld = _world
            });
            var blueDoofusEntity =
                GameObjectConversionUtility.ConvertGameObjectHierarchy(Resources.Load("BlueCapsule") as GameObject,
                                                                       new GameObjectConversionSettings()
            {
                DestinationWorld = _world
            });

            AddSveltoEngineToTick(new PlaceFoodOnClickEngine(redfoodEntity, bluefoodEntity, generateEntityFactory));
            AddSveltoEngineToTick(new SpawningDoofusEngine(redDoofusEntity, blueDoofusEntity, generateEntityFactory));
            var generateEntityFunctions = _enginesRoot.GenerateEntityFunctions();

            AddSveltoEngineToTick(new ConsumingFoodEngine(generateEntityFunctions));
            AddSveltoEngineToTick(new LookingForFoodDoofusesEngine(generateEntityFunctions));
            AddSveltoEngineToTick(new VelocityToPositionDoofusesEngine());

            AddSveltoCallbackEngine(new SpawnUnityEntityOnSveltoEntityEngine(_world));

            AddSveltoUECSEngine(new RenderingUECSDataSynchronizationEngine());

            StartTicking(_enginesToTick);

            return(true);
        }
Example #17
0
 public void OneTimeSetUp() => DefaultWorldInitialization.Initialize("Default", true);
Example #18
0
 static void Initialize()
 {
     DefaultWorldInitialization.Initialize("Default World", false);
     //GameObjectSceneUtility.AddGameObjectSceneReferences();
 }