void SelectClip(int selected) { // If you were editing Clip Name (delayed text field had focus) and then selected a new clip from the clip list, // the active string in the delayed text field would get applied to the new selected clip instead of the old. // HACK: Calling EndGUI here on the recycled delayed text editor seems to fix this issue. // Sometime we should reimplement delayed text field code to not be super confusing and then fix the issue more properly. if (EditorGUI.s_DelayedTextEditor != null && Event.current != null) { EditorGUI.s_DelayedTextEditor.EndGUI(Event.current.type); } DestroyEditorsAndData(); selectedClipIndex = selected; if (selectedClipIndex < 0 || selectedClipIndex >= m_ClipAnimations.arraySize) { selectedClipIndex = -1; return; } AnimationClipInfoProperties info = GetAnimationClipInfoAtIndex(selected); AnimationClip clip = singleImporter.GetPreviewAnimationClipForTake(info.takeName); if (clip != null) { m_AnimationClipEditor = (AnimationClipEditor)Editor.CreateEditor(clip, typeof(AnimationClipEditor)); InitMask(info); SyncClipEditor(); } }
private void SelectClip(int selected) { if (EditorGUI.s_DelayedTextEditor != null && Event.current != null) { EditorGUI.s_DelayedTextEditor.EndGUI(Event.current.type); } this.DestroyEditorsAndData(); this.selectedClipIndex = selected; if (this.selectedClipIndex < 0 || this.selectedClipIndex >= this.m_ClipAnimations.arraySize) { this.selectedClipIndex = -1; } else { AnimationClipInfoProperties animationClipInfoAtIndex = this.GetAnimationClipInfoAtIndex(selected); AnimationClip animationClipForTake = this.singleImporter.GetPreviewAnimationClipForTake(animationClipInfoAtIndex.takeName); if (!((UnityEngine.Object)animationClipForTake != (UnityEngine.Object)null)) { return; } this.m_AnimationClipEditor = (AnimationClipEditor)Editor.CreateEditor((UnityEngine.Object)animationClipForTake); this.InitMask(animationClipInfoAtIndex); this.SyncClipEditor(); } }
private void DestroyEditorsAndData() { if (this.m_AnimationClipEditor != null) { UnityEngine.Object.DestroyImmediate(this.m_AnimationClipEditor); this.m_AnimationClipEditor = null; } if (this.m_MaskInspector) { UnityEngine.Object.DestroyImmediate(this.m_MaskInspector); this.m_MaskInspector = null; } if (this.m_Mask) { UnityEngine.Object.DestroyImmediate(this.m_Mask); this.m_Mask = null; } }
void DestroyEditorsAndData() { if (m_AnimationClipEditor != null) { Object.DestroyImmediate(m_AnimationClipEditor); m_AnimationClipEditor = null; } if (m_MaskInspector) { DestroyImmediate(m_MaskInspector); m_MaskInspector = null; } if (m_Mask) { DestroyImmediate(m_Mask); m_Mask = null; } }
private void DestroyEditorsAndData() { if ((UnityEngine.Object) this.m_AnimationClipEditor != (UnityEngine.Object)null) { UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this.m_AnimationClipEditor); this.m_AnimationClipEditor = (AnimationClipEditor)null; } if ((bool)((UnityEngine.Object) this.m_MaskInspector)) { UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this.m_MaskInspector); this.m_MaskInspector = (AvatarMaskInspector)null; } if (!(bool)((UnityEngine.Object) this.m_Mask)) { return; } UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this.m_Mask); this.m_Mask = (AvatarMask)null; }
private void SelectClip(int selected) { if (EditorGUI.s_DelayedTextEditor != null && Event.current != null) { EditorGUI.s_DelayedTextEditor.EndGUI(Event.current.type); } UnityEngine.Object.DestroyImmediate(this.m_AnimationClipEditor); this.m_AnimationClipEditor = null; this.selectedClipIndex = selected; if (this.selectedClipIndex < 0 || this.selectedClipIndex >= this.m_ClipAnimations.arraySize) { this.selectedClipIndex = -1; return; } AnimationClipInfoProperties animationClipInfoAtIndex = this.GetAnimationClipInfoAtIndex(selected); AnimationClip previewAnimationClipForTake = this.singleImporter.GetPreviewAnimationClipForTake(animationClipInfoAtIndex.takeName); if (previewAnimationClipForTake != null) { this.m_AnimationClipEditor = (AnimationClipEditor)Editor.CreateEditor(previewAnimationClipForTake); this.SyncClipEditor(); } }
public override void NodeUI(UnityEditor.Graphs.GraphGUI host) { base.graphGUI = host as UnityEditor.Graphs.AnimationStateMachine.GraphGUI; Assert.NotNull(base.graphGUI); Event current = Event.current; if (UnityEditor.Graphs.AnimationStateMachine.Node.IsLeftClick()) { host.edgeGUI.EndSlotDragging(base.inputSlots.First <Slot>(), true); } if (UnityEditor.Graphs.AnimationStateMachine.Node.IsDoubleClick()) { Motion stateEffectiveMotion = AnimatorControllerTool.tool.animatorController.GetStateEffectiveMotion(this.state, AnimatorControllerTool.tool.selectedLayerIndex); if (stateEffectiveMotion is BlendTree) { base.graphGUI.tool.AddBreadCrumb(this.state); } else if (stateEffectiveMotion is AnimationClip) { Selection.activeObject = stateEffectiveMotion; AnimationClipEditor.EditWithImporter(stateEffectiveMotion as AnimationClip); } current.Use(); } if (UnityEditor.Graphs.AnimationStateMachine.Node.IsRightClick()) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Make Transition"), false, new GenericMenu.MenuFunction(this.MakeTransitionCallback)); if (base.graphGUI.rootStateMachine.defaultState == this.state) { menu.AddDisabledItem(new GUIContent("Set as Layer Default State")); } else { menu.AddItem(new GUIContent("Set as Layer Default State"), false, new GenericMenu.MenuFunction(this.SetDefaultCallback)); } menu.AddItem(new GUIContent("Copy"), false, new GenericMenu.MenuFunction(this.CopyStateCallback)); menu.AddItem(new GUIContent("Create new BlendTree in State"), false, new GenericMenu.MenuFunction(this.AddNewBlendTreeCallback)); menu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction(this.DeleteStateCallback)); menu.ShowAsContext(); current.Use(); } Rect rect = GUILayoutUtility.GetRect((float)200f, (float)10f); if ((Event.current.type == EventType.Repaint) && ((base.graphGUI.liveLinkInfo.currentState == this.state) || (base.graphGUI.liveLinkInfo.nextState == this.state))) { GUIStyle style = "MeLivePlayBackground"; GUIStyle style2 = "MeLivePlayBar"; float f = (base.graphGUI.liveLinkInfo.currentState != this.state) ? base.graphGUI.liveLinkInfo.nextStateNormalizedTime : base.graphGUI.liveLinkInfo.currentStateNormalizedTime; bool flag = (base.graphGUI.liveLinkInfo.currentState != this.state) ? base.graphGUI.liveLinkInfo.nextStateLoopTime : base.graphGUI.liveLinkInfo.currentStateLoopTime; rect = style.margin.Remove(rect); Rect position = style.padding.Remove(rect); if (flag) { if (f < 0f) { position.width = (position.width * (1f - (Mathf.Abs(f) % 1f))) + 2f; } else { position.width = (position.width * (f % 1f)) + 2f; } } else { position.width = (position.width * Mathf.Clamp(f, 0f, 1f)) + 2f; } style2.Draw(position, false, false, false, false); style.Draw(rect, false, false, false, false); } }