private bool ShouldUpdateSelection(AnimationWindowSelectionItem selectedItem) { if (selectedItem.rootGameObject == null) { return(true); } AnimationWindowSelectionItem currentlySelectedItem = this.m_AnimEditor.selectedItem; if (!(currentlySelectedItem != null)) { return(true); } if (selectedItem.rootGameObject != currentlySelectedItem.rootGameObject) { return(true); } if (currentlySelectedItem.animationClip == null) { return(true); } if (currentlySelectedItem.rootGameObject != null) { AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(currentlySelectedItem.rootGameObject); if (!Array.Exists <AnimationClip>(animationClips, (AnimationClip x) => x == currentlySelectedItem.animationClip)) { return(true); } } return(false); }
public void OnGUI() { AnimationWindowSelectionItem selectedItem = this.state.selectedItem; if (!(selectedItem == null) && selectedItem.canChangeAnimationClip) { string[] clipMenuContent = this.GetClipMenuContent(); EditorGUI.BeginChangeCheck(); this.selectedIndex = EditorGUILayout.Popup(this.ClipToIndex(this.state.activeAnimationClip), clipMenuContent, EditorStyles.toolbarPopup, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (clipMenuContent[this.selectedIndex] == AnimationWindowStyles.createNewClip.text) { AnimationClip animationClip = AnimationWindowUtility.CreateNewClip(selectedItem.rootGameObject.name); if (animationClip) { AnimationWindowUtility.AddClipToAnimationPlayerComponent(this.state.activeAnimationPlayer, animationClip); this.state.selection.UpdateClip(this.state.selectedItem, animationClip); this.state.currentTime = 0f; this.state.ResampleAnimation(); GUIUtility.ExitGUI(); } } else { this.state.selection.UpdateClip(this.state.selectedItem, this.IndexToClip(this.selectedIndex)); this.state.currentTime = 0f; this.state.ResampleAnimation(); } } } }
private void SynchronizePolicy() { if (!(this.m_AnimEditor == null)) { if (this.m_Policy == null) { this.m_Policy = new AnimationWindowPolicy(); } if (this.m_Policy.unitialized) { this.m_Policy.SynchronizeFrameRate = delegate(ref float frameRate) { AnimationWindowSelectionItem selectedItem = this.m_AnimEditor.selectedItem; if (selectedItem != null && selectedItem.animationClip != null) { frameRate = selectedItem.animationClip.frameRate; } else { frameRate = 60f; } return(true); }; this.m_Policy.unitialized = false; } this.m_AnimEditor.policy = this.m_Policy; } }
public void OnSelectionChange() { if (this.m_AnimEditor == null) { return; } GameObject activeGameObject = Selection.activeGameObject; if (activeGameObject == null) { return; } if (EditorUtility.IsPersistent(activeGameObject)) { return; } if ((activeGameObject.hideFlags & HideFlags.NotEditable) != HideFlags.None) { return; } this.SynchronizePolicy(); AnimationWindowSelectionItem selectedItem = this.BuildSelection(activeGameObject); if (!this.m_AnimEditor.locked && this.ShouldUpdateSelection(selectedItem)) { this.m_AnimEditor.state.recording = false; this.m_AnimEditor.selectedItem = selectedItem; } }
private void SynchronizePolicy() { if (this.m_AnimEditor == null) { return; } if (this.m_Policy == null) { this.m_Policy = new AnimationWindowPolicy(); this.m_Policy.allowRecording = true; } if (this.m_Policy.unitialized) { this.m_Policy.SynchronizeFrameRate = delegate(ref float frameRate, ref bool timeInFrames) { AnimationWindowSelectionItem selectedItem = this.m_AnimEditor.selectedItem; if (selectedItem != null && selectedItem.animationClip != null) { frameRate = selectedItem.animationClip.frameRate; } else { frameRate = 60f; } timeInFrames = false; return(true); }; this.m_Policy.unitialized = false; } this.m_AnimEditor.policy = this.m_Policy; }
private bool ShouldUpdateSelection(AnimationWindowSelectionItem selectedItem) { if (m_LockTracker.isLocked) { return(false); } AnimationWindowSelectionItem currentSelection = m_AnimEditor.selection; return(selectedItem.GetRefreshHash() != currentSelection.GetRefreshHash()); }
private string[] GetClipMenuContent() { List <string> list = new List <string>(); list.AddRange(this.GetClipNames()); AnimationWindowSelectionItem selectedItem = this.state.selectedItem; if (selectedItem.rootGameObject != null && selectedItem.animationIsEditable) { list.Add(""); list.Add(AnimationWindowStyles.createNewClip.text); } return(list.ToArray()); }
private bool ShouldUpdateSelection(AnimationClipSelectionItem selectedItem) { if (this.m_AnimEditor.locked) { return(false); } AnimationWindowSelectionItem item = this.m_AnimEditor.selectedItem; if (item != null) { return(selectedItem.GetRefreshHash() != item.GetRefreshHash()); } return(true); }
private bool ShouldUpdateSelection(AnimationWindowSelectionItem selectedItem) { bool result; if (this.m_LockTracker.isLocked) { result = false; } else { AnimationWindowSelectionItem selection = this.m_AnimEditor.selection; result = (selectedItem.GetRefreshHash() != selection.GetRefreshHash()); } return(result); }
private void AddEventButtonOnGUI() { AnimationWindowSelectionItem selectedItem = this.m_State.selectedItem; if (selectedItem != null) { using (new EditorGUI.DisabledScope(!selectedItem.animationIsEditable)) { if (GUILayout.Button(AnimationWindowStyles.addEventContent, EditorStyles.toolbarButton, new GUILayoutOption[0])) { this.m_Events.AddEvent(this.m_State.currentTime - selectedItem.timeOffset, selectedItem.rootGameObject, selectedItem.animationClip); } } } }
private bool ShouldUpdateSelection(AnimationClipSelectionItem selectedItem) { bool result; if (this.m_AnimEditor.locked) { result = false; } else { AnimationWindowSelectionItem selectedItem2 = this.m_AnimEditor.selectedItem; result = (!(selectedItem2 != null) || selectedItem.GetRefreshHash() != selectedItem2.GetRefreshHash()); } return(result); }
private bool ShouldUpdateSelection(GameObjectSelectionItem selectedItem) { bool result; if (this.m_AnimEditor.locked) { result = false; } else if (selectedItem.rootGameObject == null) { result = true; } else { AnimationWindowSelectionItem currentlySelectedItem = this.m_AnimEditor.selectedItem; if (currentlySelectedItem != null) { if (selectedItem.rootGameObject != currentlySelectedItem.rootGameObject) { result = true; } else if (currentlySelectedItem.animationClip == null) { result = true; } else { if (currentlySelectedItem.rootGameObject != null) { AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(currentlySelectedItem.rootGameObject); if (!Array.Exists <AnimationClip>(animationClips, (AnimationClip x) => x == currentlySelectedItem.animationClip)) { result = true; return(result); } } result = false; } } else { result = true; } } return(result); }
private bool ShouldUpdateGameObjectSelection(GameObjectSelectionItem selectedItem) { if (m_LockTracker.isLocked) { return(false); } if (state.linkedWithSequencer) { return(false); } // Selected game object with no animation player. if (selectedItem.rootGameObject == null) { return(true); } AnimationWindowSelectionItem currentSelection = m_AnimEditor.selection; // Game object holding animation player has changed. Update selection. if (selectedItem.rootGameObject != currentSelection.rootGameObject) { return(true); } // No clip in current selection, favour new selection. if (currentSelection.animationClip == null) { return(true); } // Make sure that animation clip is still referenced in animation player. if (currentSelection.rootGameObject != null) { AnimationClip[] allClips = AnimationUtility.GetAnimationClips(currentSelection.rootGameObject); if (!Array.Exists(allClips, x => x == currentSelection.animationClip)) { return(true); } } return(false); }
private void FrameRateInputFieldOnGUI() { AnimationWindowSelectionItem selectedItem = this.m_State.selectedItem; using (new EditorGUI.DisabledScope(selectedItem == null || !selectedItem.animationIsEditable)) { GUILayout.Label(AnimationWindowStyles.samples, AnimationWindowStyles.toolbarLabel, new GUILayoutOption[0]); EditorGUI.BeginChangeCheck(); int num = EditorGUILayout.DelayedIntField((int)this.m_State.clipFrameRate, EditorStyles.toolbarTextField, new GUILayoutOption[] { GUILayout.Width(35f) }); if (EditorGUI.EndChangeCheck()) { this.m_State.clipFrameRate = (float)num; this.UpdateSelectedKeysToCurveEditor(); } } }
private void AddEventButtonOnGUI() { if (this.m_State.policy != null && !this.m_State.policy.allowAddEvent) { return; } AnimationWindowSelectionItem selectedItem = this.m_State.selectedItem; if (selectedItem != null) { using (new EditorGUI.DisabledScope(!selectedItem.animationIsEditable)) { if (GUILayout.Button(AnimationWindowStyles.addEventContent, EditorStyles.toolbarButton, new GUILayoutOption[0])) { AnimationEventPopup.Create(selectedItem.rootGameObject, selectedItem.animationClip, this.m_State.currentTime - selectedItem.timeOffset, this.m_OwnerWindow); } } } }
public void OnGUI() { AnimationWindowSelectionItem selectedItem = this.state.selectedItem; if (!(selectedItem == null)) { if (selectedItem.canChangeAnimationClip) { string[] clipMenuContent = this.GetClipMenuContent(); EditorGUI.BeginChangeCheck(); this.selectedIndex = EditorGUILayout.Popup(this.ClipToIndex(this.state.activeAnimationClip), clipMenuContent, EditorStyles.toolbarPopup, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (clipMenuContent[this.selectedIndex] == AnimationWindowStyles.createNewClip.text) { AnimationClip animationClip = AnimationWindowUtility.CreateNewClip(selectedItem.rootGameObject.name); if (animationClip) { AnimationWindowUtility.AddClipToAnimationPlayerComponent(this.state.activeAnimationPlayer, animationClip); this.state.selection.UpdateClip(this.state.selectedItem, animationClip); GUIUtility.ExitGUI(); } } else { this.state.selection.UpdateClip(this.state.selectedItem, this.IndexToClip(this.selectedIndex)); } } } else if (this.state.activeAnimationClip != null) { Rect controlRect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight, AnimationWindowStyles.toolbarLabel, new GUILayoutOption[0]); EditorGUI.LabelField(controlRect, CurveUtility.GetClipName(this.state.activeAnimationClip), AnimationWindowStyles.toolbarLabel); } } }
public AddCurvesPopupPropertyNode(TreeViewItem parent, AnimationWindowSelectionItem selectionItem, EditorCurveBinding[] curveBindings) : base(curveBindings[0].GetHashCode(), parent.depth + 1, parent, AnimationWindowUtility.NicifyPropertyGroupName(curveBindings[0].type, AnimationWindowUtility.GetPropertyGroupName(curveBindings[0].propertyName))) { this.selectionItem = selectionItem; this.curveBindings = curveBindings; }