Example #1
0
        /// <summary>
        /// Cleanup function
        /// </summary>
        protected virtual void OnDestroy()
        {
            Physics.gravity       = originalGravity;
            Time.fixedDeltaTime   = originalFixedDeltaTime;
            Time.maximumDeltaTime = originalMaximumDeltaTime;
            broadcastHub.Clear();
            broadcastHub = null;
            agentSpawner = null;

            // Signal to listeners that the academy is being destroyed now
            DestroyAction();
        }
        /// <summary>
        /// Lazy initializes the Drawer with the property to be drawn.
        /// </summary>
        /// <param name="property">The SerializedProperty of the EnvironmentSpawner
        /// to make the custom GUI for.</param>
        /// <param name="label">The label of this property.</param>
        private void LazyInitialize(SerializedProperty property, GUIContent label)
        {
            if (_envSpawner != null)
            {
                return;
            }
            var target = property.serializedObject.targetObject;

            _envSpawner = fieldInfo.GetValue(target) as EnvSpawner;
            if (_envSpawner == null)
            {
                _envSpawner = new EnvSpawner();
                fieldInfo.SetValue(target, _envSpawner);
            }
        }