void AnimationSplitTable() { if (m_ClipList == null) { m_ClipList = new ReorderableList(new List <AnimationClipInfoProperties>(), typeof(string), false, true, true, true); m_ClipList.onAddCallback = AddClipInList; m_ClipList.onSelectCallback = SelectClipInList; m_ClipList.onRemoveCallback = RemoveClipInList; m_ClipList.drawElementCallback = DrawClipElement; m_ClipList.drawHeaderCallback = DrawClipHeader; m_ClipList.elementHeight = 16; UpdateList(); m_ClipList.index = selectedClipIndex; } m_ClipList.DoLayoutList(); EditorGUI.BeginChangeCheck(); // Show selected clip info { AnimationClipInfoProperties clip = GetSelectedClipInfo(); if (clip == null) { return; } if (m_AnimationClipEditor != null && selectedClipIndex != -1) { GUILayout.Space(5); AnimationClip actualClip = m_AnimationClipEditor.target as AnimationClip; if (!actualClip.legacy) { GetSelectedClipInfo().AssignToPreviewClip(actualClip); } TakeInfo[] importedTakeInfos = singleImporter.importedTakeInfos; string[] takeNames = new string[importedTakeInfos.Length]; for (int i = 0; i < importedTakeInfos.Length; i++) { takeNames[i] = importedTakeInfos[i].name; } EditorGUI.BeginChangeCheck(); string currentName = clip.name; int takeIndex = ArrayUtility.IndexOf(takeNames, clip.takeName); m_AnimationClipEditor.takeNames = takeNames; m_AnimationClipEditor.takeIndex = ArrayUtility.IndexOf(takeNames, clip.takeName); m_AnimationClipEditor.DrawHeader(); if (EditorGUI.EndChangeCheck()) { // We renamed the clip name, try to maintain the localIdentifierInFile so we don't lose any data. if (clip.name != currentName) { TransferDefaultClipsToCustomClips(); PatchImportSettingRecycleID.Patch(serializedObject, 74, currentName, clip.name); } int newTakeIndex = m_AnimationClipEditor.takeIndex; if (newTakeIndex != -1 && newTakeIndex != takeIndex) { clip.name = MakeUniqueClipName(takeNames[newTakeIndex]); SetupTakeNameAndFrames(clip, importedTakeInfos[newTakeIndex]); GUIUtility.keyboardControl = 0; SelectClip(selectedClipIndex); // actualClip has been changed by SelectClip actualClip = m_AnimationClipEditor.target as AnimationClip; } } m_AnimationClipEditor.OnInspectorGUI(); AvatarMaskSettings(GetSelectedClipInfo()); if (!actualClip.legacy) { GetSelectedClipInfo().ExtractFromPreviewClip(actualClip); } } } if (EditorGUI.EndChangeCheck() || m_AnimationClipEditor.needsToGenerateClipInfo) { TransferDefaultClipsToCustomClips(); m_AnimationClipEditor.needsToGenerateClipInfo = false; } }
void AnimationSplitTable() { m_ClipList.DoLayoutList(); EditorGUI.BeginChangeCheck(); // Show selected clip info { AnimationClipInfoProperties clip = GetSelectedClipInfo(); if (clip == null) { return; } if (m_AnimationClipEditor != null) { GUILayout.Space(5); AnimationClip actualClip = m_AnimationClipEditor.target as AnimationClip; if (!actualClip.legacy) { clip.AssignToPreviewClip(actualClip); } TakeInfo[] importedTakeInfos = singleImporter.importedTakeInfos; string[] takeNames = new string[importedTakeInfos.Length]; for (int i = 0; i < importedTakeInfos.Length; i++) { takeNames[i] = importedTakeInfos[i].name; } EditorGUI.BeginChangeCheck(); string currentName = clip.name; int takeIndex = ArrayUtility.IndexOf(takeNames, clip.takeName); m_AnimationClipEditor.takeNames = takeNames; m_AnimationClipEditor.takeIndex = ArrayUtility.IndexOf(takeNames, clip.takeName); m_AnimationClipEditor.DrawHeader(); if (EditorGUI.EndChangeCheck()) { clip.name = clip.name.Trim(); if (clip.name == String.Empty) { clip.name = currentName; } // We renamed the clip name, try to maintain the localIdentifierInFile so we don't lose any data. if (clip.name != currentName) { var newName = clip.name; clip.name = currentName; clip.name = MakeUniqueClipName(newName); TransferDefaultClipsToCustomClips(); UnityType animationClipType = UnityType.FindTypeByName("AnimationClip"); ImportSettingInternalID.Rename(serializedObject, animationClipType, currentName, clip.name); } int newTakeIndex = m_AnimationClipEditor.takeIndex; if (newTakeIndex != -1 && newTakeIndex != takeIndex) { clip.name = MakeUniqueClipName(takeNames[newTakeIndex]); SetupTakeNameAndFrames(clip, importedTakeInfos[newTakeIndex]); GUIUtility.keyboardControl = 0; SelectClip(m_ClipList.index); // actualClip has been changed by SelectClip actualClip = m_AnimationClipEditor.target as AnimationClip; } } m_AnimationClipEditor.OnInspectorGUI(); AvatarMaskSettings(clip); if (!actualClip.legacy) { clip.ExtractFromPreviewClip(actualClip); } if (EditorGUI.EndChangeCheck() || m_AnimationClipEditor.needsToGenerateClipInfo) { TransferDefaultClipsToCustomClips(); m_AnimationClipEditor.needsToGenerateClipInfo = false; } } } }