void OnLayerDeleted(SerializedProperty arrayProperty, int indexToRemove) { StateLayer layer = arrayProperty.GetArrayElementAtIndex(indexToRemove).GetValue<StateLayer>(); for (int i = 0; i < statesProperty.arraySize; i++) { State state = statesProperty.GetArrayElementAtIndex(i).GetValue<State>(); if (state != null) { state.Remove(); } } layer.Remove(); DeleteFromArray(arrayProperty, indexToRemove); }
public static void RemoveLayer(StateLayer layer) { #if UNITY_EDITOR UnityEditor.SerializedObject layerSerialized = new UnityEditor.SerializedObject(layer); UnityEditor.SerializedProperty statesProperty = layerSerialized.FindProperty("stateReferences"); foreach (UnityEngine.Object state in statesProperty.GetValues <UnityEngine.Object>()) { if (state is StateLayer) { RemoveLayer(state as StateLayer); } else { state.Remove(); } } layer.Remove(); #endif }
public static void RemoveLayer(StateLayer layer) { #if UNITY_EDITOR UnityEditor.SerializedObject layerSerialized = new UnityEditor.SerializedObject(layer); UnityEditor.SerializedProperty statesProperty = layerSerialized.FindProperty("stateReferences"); foreach (UnityEngine.Object state in statesProperty.GetValues<UnityEngine.Object>()) { if (state is StateLayer) { RemoveLayer(state as StateLayer); } else { state.Remove(); } } layer.Remove(); #endif }