void OnLayerAdded(SerializedProperty arrayProperty) { AddToArray(arrayProperty); StateLayer newLayer = stateMachineObject.AddComponent(selectedLayerType) as StateLayer; newLayer.machine = stateMachine; newLayer.hideFlags = HideFlags.HideInInspector; arrayProperty.GetLastArrayElement().SetValue(newLayer); }