/// <summary> /// Enable stepping of the Academy during the FixedUpdate phase. This is done by creating /// a temporary GameObject with a MonoBehaviour that calls Academy.EnvironmentStep(). /// </summary> void EnableAutomaticStepping() { if (m_FixedUpdateStepper != null) { return; } m_StepperObject = new GameObject("AcademyFixedUpdateStepper"); // Don't show this object in the hierarchy m_StepperObject.hideFlags = HideFlags.HideInHierarchy; m_FixedUpdateStepper = m_StepperObject.AddComponent <AcademyFixedUpdateStepper>(); try { // This try-catch is because DontDestroyOnLoad cannot be used in Editor Tests GameObject.DontDestroyOnLoad(m_StepperObject); } catch { } }
/// <summary> /// Disable stepping of the Academy during the FixedUpdate phase. If this is called, the Academy must be /// stepped manually by the user by calling Academy.EnvironmentStep(). /// </summary> void DisableAutomaticStepping() { if (m_FixedUpdateStepper == null) { return; } m_FixedUpdateStepper = null; if (Application.isEditor) { UnityEngine.Object.DestroyImmediate(m_StepperObject); } else { UnityEngine.Object.Destroy(m_StepperObject); } m_StepperObject = null; }
/// <summary> /// Check if the input AcademyFixedUpdateStepper belongs to this Academy. /// </summary> internal bool IsStepperOwner(AcademyFixedUpdateStepper stepper) { return(GameObject.ReferenceEquals(stepper.gameObject, Academy.Instance.m_StepperObject)); }