/// <summary> /// The list has been reordered. Ensure the reorder is valid. /// </summary> private void OnAnimatorAudioStateSetStateListReorder(ReorderableList list) { var animatorAudioState = m_ShootableWeapon.ReloadAnimatorAudioStateSet.States[EditorPrefs.GetInt(SelectedReloadAnimatorAudioStateSetIndexKey)]; // Use the dummy array in order to determine what element the selected index was swapped with. var copiedStates = new Shared.StateSystem.State[animatorAudioState.States.Length]; Array.Copy(animatorAudioState.States, copiedStates, animatorAudioState.States.Length); for (int i = 0; i < animatorAudioState.States.Length; ++i) { var element = list.serializedProperty.GetArrayElementAtIndex(i); if (element.intValue != i) { animatorAudioState.States[i] = copiedStates[element.intValue]; element.intValue = i; } } var states = StateInspector.OnStateListReorder(animatorAudioState.States); if (animatorAudioState.States.Length != states.Length) { InspectorUtility.SynchronizePropertyCount(states, m_ReorderableReloadAnimatorAudioStateSetStateList.serializedProperty); Shared.Editor.Utility.EditorUtility.RecordUndoDirtyObject(target, "Change Value"); animatorAudioState.States = states; } }
/// <summary> /// The list has been reordered. Ensure the reorder is valid. /// </summary> private void OnViewTypeStateListReorder(ReorderableList list) { var viewType = m_CameraController.ViewTypes[EditorPrefs.GetInt(SelectedViewTypeIndexKey)]; // Use the dummy array in order to determine what element the selected index was swapped with. var copiedStates = new Shared.StateSystem.State[viewType.States.Length]; Array.Copy(viewType.States, copiedStates, viewType.States.Length); for (int i = 0; i < viewType.States.Length; ++i) { var element = list.serializedProperty.GetArrayElementAtIndex(i); if (element.intValue != i) { viewType.States[i] = copiedStates[element.intValue]; element.intValue = i; } } var states = StateInspector.OnStateListReorder(viewType.States); if (viewType.States.Length != states.Length) { InspectorUtility.SynchronizePropertyCount(states, m_ReorderableViewTypeStateList.serializedProperty); Shared.Editor.Utility.EditorUtility.RecordUndoDirtyObject(target, "Change Value"); viewType.States = states; SerializeViewTypes(); } }
/// <summary> /// The list has been reordered. Ensure the reorder is valid. /// </summary> private void OnItemSetStateListReorder(ReorderableList list) { m_ItemSetListIndex = m_ReorderableListCategoryMap[list]; var itemSet = m_ItemSetManager.CategoryItemSets[m_ItemSetListIndex].ItemSetList[EditorPrefs.GetInt(SelectedItemSetIndexKey, -1)]; // Use the dummy array in order to determine what element the selected index was swapped with. var copiedStates = new Shared.StateSystem.State[itemSet.States.Length]; System.Array.Copy(itemSet.States, copiedStates, itemSet.States.Length); for (int i = 0; i < itemSet.States.Length; ++i) { var element = list.serializedProperty.GetArrayElementAtIndex(i); if (element.intValue != i) { itemSet.States[i] = copiedStates[element.intValue]; element.intValue = i; } } var states = StateInspector.OnStateListReorder(itemSet.States); if (itemSet.States.Length != states.Length) { InspectorUtility.SynchronizePropertyCount(states, m_ReorderableItemSetStateList[m_ItemSetListIndex].serializedProperty); Shared.Editor.Utility.EditorUtility.RecordUndoDirtyObject(target, "Change Value"); itemSet.States = states; } }