public void DeleteTransitionAtIndex(int index) { if (index < 0 || index >= TransitionsProp.arraySize) { return; } SerializedTransition currentTrans = GetTransitionAtIndex(index); Undo.SetCurrentGroupName("Delete Transition"); int currentGroup = Undo.GetCurrentGroup(); Undo.RegisterCompleteObjectUndo(SerializedObject.targetObject, "Scene Data"); for (int i = 0; i < currentTrans.ConditionsProp.arraySize; i++) { SerializedProperty currentCond = currentTrans.ConditionsProp.GetArrayElementAtIndex(i); Undo.DestroyObjectImmediate(currentCond.objectReferenceValue); } TransitionsProp.DeleteArrayElementAtIndex(index); Undo.CollapseUndoOperations(currentGroup); SerializedObject.ApplyModifiedProperties(); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(SerializedObject.targetObject)); }
/// <summary> /// Gets the serialized transition at the provided index /// </summary> /// <param name="transitionIndex">The index of the transition</param> /// <returns>Serialized representation of the transition</returns> public SerializedTransition GetTransitionAtIndex(int transitionIndex) { return(new SerializedTransition(TransitionsProp.GetArrayElementAtIndex(transitionIndex))); }