Ejemplo n.º 1
0
        public static void RemoveLayer(StateMachine machine, StateLayer layer)
        {
#if UNITY_EDITOR
            var layerSerialized = new UnityEditor.SerializedObject(layer);
            var statesProperty  = layerSerialized.FindProperty("stateReferences");
            var states          = statesProperty.GetValues <UnityEngine.Object>();

            for (int i = 0; i < states.Length; i++)
            {
                var state    = states[i];
                var sublayer = state as StateLayer;

                if (sublayer != null)
                {
                    RemoveLayer(machine, sublayer);
                }
                else
                {
                    state.Destroy();
                }
            }

            layer.Destroy();
            UpdateCallbacks(machine);
#endif
        }
        public static void RemoveLayer(StateMachine machine, StateLayer layer)
        {
            #if UNITY_EDITOR
            var layerSerialized = new UnityEditor.SerializedObject(layer);
            var statesProperty = layerSerialized.FindProperty("stateReferences");
            var states = statesProperty.GetValues<UnityEngine.Object>();

            for (int i = 0; i < states.Length; i++)
            {
                var state = states[i];
                var sublayer = state as StateLayer;

                if (sublayer != null)
                    RemoveLayer(machine, sublayer);
                else
                    state.Destroy();
            }

            layer.Destroy();
            UpdateCallbacks(machine);
            #endif
        }