public void CurrentPlayerLoopWrappers_Work() { using (var world = new World("Test World")) { // world must have at least one of the default top-level groups to add var initSysGroup = world.CreateSystem <InitializationSystemGroup>(); Assert.IsFalse(ScriptBehaviourUpdateOrder.IsWorldInCurrentPlayerLoop(world)); ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(world); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInCurrentPlayerLoop(world)); ScriptBehaviourUpdateOrder.RemoveWorldFromCurrentPlayerLoop(world); Assert.IsFalse(ScriptBehaviourUpdateOrder.IsWorldInCurrentPlayerLoop(world)); } }
public void Setup() { PreviousGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld; if (PreviousGameObjectInjectionWorld != null) { _wasInPlayerLoop = ScriptBehaviourUpdateOrder.IsWorldInCurrentPlayerLoop(PreviousGameObjectInjectionWorld); if (_wasInPlayerLoop) { ScriptBehaviourUpdateOrder.RemoveWorldFromCurrentPlayerLoop(PreviousGameObjectInjectionWorld); } } else { _wasInPlayerLoop = false; } World.DefaultGameObjectInjectionWorld = null; }
public void AddRemoveScriptUpdate() { DefaultWorldInitialization.Initialize("Test World", true); var newWorld = new World("WorldA"); newWorld.CreateSystem <InitializationSystemGroup>(); newWorld.CreateSystem <SimulationSystemGroup>(); newWorld.CreateSystem <PresentationSystemGroup>(); Assert.IsFalse(ScriptBehaviourUpdateOrder.IsWorldInCurrentPlayerLoop(newWorld)); ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(newWorld); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInCurrentPlayerLoop(newWorld)); PlayerLoop.SetPlayerLoop(PlayerLoop.GetDefaultPlayerLoop()); Assert.IsFalse(ScriptBehaviourUpdateOrder.IsWorldInCurrentPlayerLoop(newWorld)); var playerLoop = PlayerLoop.GetDefaultPlayerLoop(); ScriptBehaviourUpdateOrder.AddWorldToPlayerLoop(World.DefaultGameObjectInjectionWorld, ref playerLoop); PlayerLoop.SetPlayerLoop(playerLoop); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInCurrentPlayerLoop(World.DefaultGameObjectInjectionWorld)); }