コード例 #1
0
        public static void Reset()
        {
            World.DisposeAllWorlds();

            PlayerLoopUtil.ResetPlayerLoop();

            ReferenceTypeUtil.Clear();

            ManagedMonoBehaviour.DestroyAll();

            TimeUtil.TimeOffset = 0;
        }
コード例 #2
0
    public bool ArrayContains(ManagedMonoBehaviour[] _array, ManagedMonoBehaviour _behaviour)
    {
        int length = _array.Length;

        for (int i = 0; i < length; i++)
        {
            if (_behaviour == _array[i])
            {
                return(true);
            }
        }

        return(false);
    }
コード例 #3
0
    public ManagedMonoBehaviour[] ExtendArrayAndAddBehaviour(ManagedMonoBehaviour[] _array, ManagedMonoBehaviour _behaviour)
    {
        int length = _array.Length;

        ManagedMonoBehaviour[] extendedArray = new ManagedMonoBehaviour[length + 1];

        for (int i = 0; i < length; i++)
        {
            extendedArray[i] = _array[i];
        }

        extendedArray[extendedArray.Length - 1] = _behaviour;
        return(extendedArray);
    }
コード例 #4
0
    public ManagedMonoBehaviour[] RetractArrayAndRemoveBehaviour(ManagedMonoBehaviour[] _array, ManagedMonoBehaviour _behaviour)
    {
        int length = _array.Length;

        ManagedMonoBehaviour[] retractedArray = new ManagedMonoBehaviour[length - 1];

        for (int i = 0; i < length; i++)
        {
            if (_array[i] == _behaviour)
            {
                continue;
            }
            retractedArray[i] = _array[i];
        }

        return(retractedArray);
    }
コード例 #5
0
    private void Start()
    {
        Scene currentScene = SceneManager.GetActiveScene();

        GameObject[] rootObjects = currentScene.GetRootGameObjects();

        //Searching the scene for objects with managed MonoBehaviours and adding them to the array
        for (int i = 0; i < rootObjects.Length; i++)
        {
            Component[] objectBehaviours = rootObjects[i].GetComponents(typeof(ManagedMonoBehaviour));
            if (objectBehaviours.Length > 0)
            {
                for (int j = 0; j < objectBehaviours.Length; j++)
                {
                    ManagedMonoBehaviour newBehaviour = (ManagedMonoBehaviour)objectBehaviours[j];
                    Add(newBehaviour);
                }
            }
        }
    }
コード例 #6
0
 private void RemoveFromArray(ManagedMonoBehaviour _behaviour)
 {
     if (ArrayContains(update, _behaviour))
     {
         update = RetractArrayAndRemoveBehaviour(update, _behaviour);
         updateCount--;
     }
     else if (ArrayContains(fixedUpdate, _behaviour))
     {
         fixedUpdate = RetractArrayAndRemoveBehaviour(fixedUpdate, _behaviour);
         fixedUpdateCount--;
     }
     else if (ArrayContains(lateUpdate, _behaviour))
     {
         lateUpdate = RetractArrayAndRemoveBehaviour(lateUpdate, _behaviour);
         lateUpdateCount--;
     }
     else
     {
         return;
     }
 }
コード例 #7
0
 private void AddToArray(ManagedMonoBehaviour _behaviour)
 {
     if (_behaviour.GetType().GetMethod("ManagedUpdate").DeclaringType != typeof(ManagedMonoBehaviour))
     {
         update = ExtendArrayAndAddBehaviour(update, _behaviour);
         updateCount++;
     }
     else if (_behaviour.GetType().GetMethod("ManagedFixedUpdate").DeclaringType != typeof(ManagedMonoBehaviour))
     {
         fixedUpdate = ExtendArrayAndAddBehaviour(fixedUpdate, _behaviour);
         fixedUpdateCount++;
     }
     else if (_behaviour.GetType().GetMethod("ManagedLateUpdate").DeclaringType != typeof(ManagedMonoBehaviour))
     {
         lateUpdate = ExtendArrayAndAddBehaviour(lateUpdate, _behaviour);
         lateUpdateCount++;
     }
     else
     {
         return;
     }
 }
 protected override void OnUpdate()
 {
     JobHandleExtensions.CompleteJobList();
     ManagedMonoBehaviour.DoUpdate();
 }
コード例 #9
0
 public static void RemoveAndDestroy(ManagedMonoBehaviour _behaviour)
 {
     instance.RemoveFromArray(_behaviour);
     Destroy(_behaviour.gameObject);
 }
コード例 #10
0
 public static void Remove(ManagedMonoBehaviour _behaviour)
 {
     instance.RemoveFromArray(_behaviour);
 }
コード例 #11
0
 public static void Add(ManagedMonoBehaviour _behaviour)
 {
     instance.AddToArray(_behaviour);
 }