public static void Reset() { World.DisposeAllWorlds(); PlayerLoopUtil.ResetPlayerLoop(); ReferenceTypeUtil.Clear(); ManagedMonoBehaviour.DestroyAll(); TimeUtil.TimeOffset = 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); }
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); }
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); }
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); } } } }
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; } }
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(); }
public static void RemoveAndDestroy(ManagedMonoBehaviour _behaviour) { instance.RemoveFromArray(_behaviour); Destroy(_behaviour.gameObject); }
public static void Remove(ManagedMonoBehaviour _behaviour) { instance.RemoveFromArray(_behaviour); }
public static void Add(ManagedMonoBehaviour _behaviour) { instance.AddToArray(_behaviour); }