public static void AddWorldToPlayerLoop(World world, ref PlayerLoopSystem playerLoop) { if (world == null) { return; } var initGroup = world.GetExistingSystem <SimInitializationSystemGroup>(); if (initGroup != null) { ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(initGroup, ref playerLoop, typeof(Initialization)); } var simGroup = world.GetExistingSystem <SimSimulationSystemGroup>(); if (simGroup != null) { ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(simGroup, ref playerLoop, typeof(Update)); } var presGroup = world.GetExistingSystem <SimPresentationSystemGroup>(); if (presGroup != null) { ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(presGroup, ref playerLoop, typeof(PreLateUpdate)); } }
public void AppendSystemToPlayerLoopList_AddToNestedList_Works() { using (var world = new World("Test World")) { var playerLoop = PlayerLoop.GetDefaultPlayerLoop(); var sys = world.CreateSystem <TestSystem>(); Type targetStageType = typeof(PreLateUpdate.LegacyAnimationUpdate); ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(sys, ref playerLoop, targetStageType); ValidatePostAppendPlayerLoop(playerLoop, targetStageType, sys); } }
/// <summary> /// Update the PlayerLoop to run simulation after rendering. /// </summary> /// <param name="world">World with root-level systems that need insertion into the player loop</param> public static void AddWorldToCurrentPlayerLoopWithDelayedSimulation(World world) { var playerLoop = PlayerLoop.GetCurrentPlayerLoop(); if (world != null) { ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(world.GetExistingSystem <InitializationSystemGroup>(), ref playerLoop, typeof(Initialization)); ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(world.GetExistingSystem <SimulationSystemGroup>(), ref playerLoop, typeof(PostLateUpdate)); ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(world.GetExistingSystem <PresentationSystemGroup>(), ref playerLoop, typeof(PreLateUpdate)); } PlayerLoop.SetPlayerLoop(playerLoop); }
public void AppendSystemToPlayerLoopList_InvalidPlayerLoopSystemType_Throws() { using (var world = new World("Test World")) { var sys = world.CreateSystem <TestSystem>(); var playerLoop = PlayerLoop.GetCurrentPlayerLoop(); Assert.That( () => ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(sys, ref playerLoop, typeof(InvalidPlayerLoopSystemType)), Throws.ArgumentException.With.Message.Matches( @"Could not find PlayerLoopSystem with type=.+InvalidPlayerLoopSystemType")); } }
public bool Initialize(string defaultWorldName) { var world = new LatiosWorld(defaultWorldName); World.DefaultGameObjectInjectionWorld = world; world.useExplicitSystemOrdering = true; var initializationSystemGroup = world.initializationSystemGroup; var simulationSystemGroup = world.simulationSystemGroup; var presentationSystemGroup = world.presentationSystemGroup; var systems = new List <Type>(DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default)); systems.RemoveSwapBack(typeof(LatiosInitializationSystemGroup)); systems.RemoveSwapBack(typeof(LatiosSimulationSystemGroup)); systems.RemoveSwapBack(typeof(LatiosPresentationSystemGroup)); systems.RemoveSwapBack(typeof(InitializationSystemGroup)); systems.RemoveSwapBack(typeof(SimulationSystemGroup)); systems.RemoveSwapBack(typeof(PresentationSystemGroup)); BootstrapTools.InjectUnitySystems(systems, world, simulationSystemGroup); BootstrapTools.InjectRootSuperSystems(systems, world, simulationSystemGroup); initializationSystemGroup.SortSystems(); simulationSystemGroup.SortSystems(); presentationSystemGroup.SortSystems(); //Reset playerloop so we don't infinitely add systems. PlayerLoop.SetPlayerLoop(PlayerLoop.GetDefaultPlayerLoop()); var beforeGpuProfiling = world.CreateSystem <Lsss.Tools.BeginGpuWaitProfilingSystem>(); var afterGpuProfiling = world.CreateSystem <Lsss.Tools.EndGpuWaitProfilingSystem>(); BootstrapTools.AddWorldToCurrentPlayerLoopWithDelayedSimulation(world); var loop = PlayerLoop.GetCurrentPlayerLoop(); #if UNITY_EDITOR ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(beforeGpuProfiling, ref loop, typeof(PostLateUpdate)); #else ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList(beforeGpuProfiling, ref loop, typeof(UnityEngine.PlayerLoop.PostLateUpdate.PlayerEmitCanvasGeometry)); #endif PlayerLoop.SetPlayerLoop(loop); return(true); }