コード例 #1
0
        // [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
        public static void Initialize()
        {
            lock (Runners)
            {
                if (initialized)
                {
                    return;
                }
                initialized = true;
            }

            for (var i = 0; i < Runners.Length; i++)
            {
                Runners[i] = new PlayerLoopRunner();
            }

            var playerLoop =
#if UNITY_2019_3_OR_NEWER
                PlayerLoop.GetCurrentPlayerLoop();
#else
                PlayerLoop.GetDefaultPlayerLoop();
#endif

            var copyList = playerLoop.subSystemList;

            ref var initializeSystem = ref FindSubSystem(typeof(Initialization), copyList);
コード例 #2
0
        // [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
        public static void Initialize()
        {
            if (Interlocked.CompareExchange(ref initialized, 1, 0) != 0)
            {
                return;
            }

            for (var i = 0; i < Runners.Length; i++)
            {
                Runners[i] = new PlayerLoopRunner();
            }

            var playerLoop =
#if UNITY_2019_3_OR_NEWER
                PlayerLoop.GetCurrentPlayerLoop();
#else
                PlayerLoop.GetDefaultPlayerLoop();
#endif

            var copyList = playerLoop.subSystemList;

            ref var initializeSystem = ref FindSubSystem(typeof(Initialization), copyList);
コード例 #3
0
ファイル: PlayerLoopHelper.cs プロジェクト: monry/VContainer
        // [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
        public static void Initialize()
        {
            lock (Runners)
            {
                if (initialized)
                {
                    return;
                }
                initialized = true;
            }

            for (var i = 0; i < Runners.Length; i++)
            {
                Runners[i] = new PlayerLoopRunner();
            }

            var playerLoop =
#if UNITY_2019_3_OR_NEWER
                PlayerLoop.GetCurrentPlayerLoop();
#else
                PlayerLoop.GetDefaultPlayerLoop();
#endif

            var copyList = playerLoop.subSystemList;

            InsertSubsystem(
                ref copyList[EarlyUpdateSystemIndex],
                typeof(EarlyUpdate.ScriptRunDelayedStartupFrame),
                new PlayerLoopSystem
            {
                type           = typeof(VContainerDelayedStartupFrame),
                updateDelegate = Runners[(int)PlayerLoopTiming.Initialization].Run
            },
                new PlayerLoopSystem
            {
                type           = typeof(VContainerPostEarlyUpdate),
                updateDelegate = Runners[(int)PlayerLoopTiming.PostInitialization].Run
            });

            InsertSubsystem(
                ref copyList[FixedUpdateSystemIndex],
                typeof(FixedUpdate.ScriptRunBehaviourFixedUpdate),
                new PlayerLoopSystem
            {
                type           = typeof(VContainerFixedUpdate),
                updateDelegate = Runners[(int)PlayerLoopTiming.FixedUpdate].Run
            },
                new PlayerLoopSystem
            {
                type           = typeof(VContainerPostFixedUpdate),
                updateDelegate = Runners[(int)PlayerLoopTiming.PostFixedUpdate].Run
            });

            InsertSubsystem(
                ref copyList[UpdateSystemIndex],
                typeof(Update.ScriptRunBehaviourUpdate),
                new PlayerLoopSystem
            {
                type           = typeof(VContainerUpdate),
                updateDelegate = Runners[(int)PlayerLoopTiming.Update].Run
            },
                new PlayerLoopSystem
            {
                type           = typeof(VContainerPostUpdate),
                updateDelegate = Runners[(int)PlayerLoopTiming.PostUpdate].Run
            });

            InsertSubsystem(
                ref copyList[PreLateUpdateSystemIndex],
                typeof(PreLateUpdate.ScriptRunBehaviourLateUpdate),
                new PlayerLoopSystem
            {
                type           = typeof(VContainerLateUpdate),
                updateDelegate = Runners[(int)PlayerLoopTiming.LateUpdate].Run
            },
                new PlayerLoopSystem
            {
                type           = typeof(VContainerPostLateUpdate),
                updateDelegate = Runners[(int)PlayerLoopTiming.PostLateUpdate].Run
            });

            playerLoop.subSystemList = copyList;
            PlayerLoop.SetPlayerLoop(playerLoop);
        }