コード例 #1
0
        public void OnEnable()
        {
            hideFlags = HideFlags.HideAndDontSave;
            s_AnimationWindows.Add(this);

            if (m_State == null)
            {
                m_State            = CreateInstance(typeof(AnimationWindowState)) as AnimationWindowState;
                m_State.hideFlags  = HideFlags.HideAndDontSave;
                m_State.animEditor = this;
                InitializeHorizontalSplitter();
                InitializeClipSelection();
                InitializeDopeSheet();
                InitializeEvents();
                InitializeCurveEditor();
                InitializeOverlay();
            }

            InitializeNonserializedValues();

            m_State.timeArea  = m_State.showCurveEditor ? (TimeArea)m_CurveEditor : m_DopeSheet;
            m_DopeSheet.state = m_State;
            m_ClipPopup.state = m_State;
            m_Overlay.state   = m_State;

            m_CurveEditor.curvesUpdated += SaveChangedCurvesFromCurveEditor;
            m_CurveEditor.OnEnable();

            m_AnimationShortcutContex = new AnimationShortcutContex(this);
            ShortcutIntegration.instance.contextManager.RegisterToolContext(m_AnimationShortcutContex);
        }
コード例 #2
0
ファイル: AnimEditor.cs プロジェクト: yiifans/UnityDecompiled
        public void OnEnable()
        {
            base.hideFlags = HideFlags.HideAndDontSave;
            AnimEditor.s_AnimationWindows.Add(this);
            if (this.m_State == null)
            {
                this.m_State            = (ScriptableObject.CreateInstance(typeof(AnimationWindowState)) as AnimationWindowState);
                this.m_State.hideFlags  = HideFlags.HideAndDontSave;
                this.m_State.animEditor = this;
                this.InitializeHorizontalSplitter();
                this.InitializeClipSelection();
                this.InitializeDopeSheet();
                this.InitializeEvents();
                this.InitializeCurveEditor();
            }
            this.InitializeNonserializedValues();
            this.m_State.timeArea  = ((!this.m_State.showCurveEditor) ? this.m_DopeSheet : this.m_CurveEditor);
            this.m_DopeSheet.state = this.m_State;
            this.m_ClipPopup.state = this.m_State;
            CurveEditor expr_CF = this.m_CurveEditor;

            expr_CF.curvesUpdated = (CurveEditor.CallbackFunction)Delegate.Combine(expr_CF.curvesUpdated, new CurveEditor.CallbackFunction(this.SaveChangedCurvesFromCurveEditor));
            AnimationWindowSelection expr_FB = this.m_State.selection;

            expr_FB.onSelectionChanged = (Action)Delegate.Combine(expr_FB.onSelectionChanged, new Action(this.OnSelectionChanged));
        }
コード例 #3
0
        public void OnEnable()
        {
            base.hideFlags = HideFlags.HideAndDontSave;
            AnimEditor.s_AnimationWindows.Add(this);
            if (this.m_State == null)
            {
                this.m_State            = (ScriptableObject.CreateInstance(typeof(AnimationWindowState)) as AnimationWindowState);
                this.m_State.hideFlags  = HideFlags.HideAndDontSave;
                this.m_State.animEditor = this;
                this.InitializeHorizontalSplitter();
                this.InitializeClipSelection();
                this.InitializeDopeSheet();
                this.InitializeEvents();
                this.InitializeCurveEditor();
                this.InitializeOverlay();
            }
            this.InitializeNonserializedValues();
            this.m_State.timeArea  = ((!this.m_State.showCurveEditor) ? this.m_DopeSheet : this.m_CurveEditor);
            this.m_DopeSheet.state = this.m_State;
            this.m_ClipPopup.state = this.m_State;
            this.m_Overlay.state   = this.m_State;
            CurveEditor expr_E9 = this.m_CurveEditor;

            expr_E9.curvesUpdated = (CurveEditor.CallbackFunction)Delegate.Combine(expr_E9.curvesUpdated, new CurveEditor.CallbackFunction(this.SaveChangedCurvesFromCurveEditor));
            this.m_CurveEditor.OnEnable();
            EditorApplication.globalEventHandler = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.globalEventHandler, new EditorApplication.CallbackFunction(this.HandleGlobalHotkeys));
        }
コード例 #4
0
        public void AddEvent(AnimationWindowState state)
        {
            float time  = ((float)state.frame) / state.frameRate;
            int   index = AnimationEventPopup.Create(state.activeRootGameObject, state.activeAnimationClip, time, this.m_Owner);

            this.Select(state.activeAnimationClip, index);
        }
コード例 #5
0
        public void OnEnable()
        {
            hideFlags = HideFlags.HideAndDontSave;
            s_AnimationWindows.Add(this);

            if (m_State == null)
            {
                m_State            = CreateInstance(typeof(AnimationWindowState)) as AnimationWindowState;
                m_State.hideFlags  = HideFlags.HideAndDontSave;
                m_State.animEditor = this;
                InitializeHorizontalSplitter();
                InitializeClipSelection();
                InitializeDopeSheet();
                InitializeEvents();
                InitializeCurveEditor();
                InitializeOverlay();
            }

            InitializeNonserializedValues();

            m_State.timeArea  = m_State.showCurveEditor ? (TimeArea)m_CurveEditor : m_DopeSheet;
            m_DopeSheet.state = m_State;
            m_ClipPopup.state = m_State;
            m_Overlay.state   = m_State;

            m_CurveEditor.curvesUpdated += SaveChangedCurvesFromCurveEditor;
            m_CurveEditor.OnEnable();

            EditorApplication.globalEventHandler += HandleGlobalHotkeys;
        }
コード例 #6
0
ファイル: AnimEditor.cs プロジェクト: yiifans/UnityDecompiled
        private void InitializeNonserializedValues()
        {
            AnimationWindowState expr_06 = this.m_State;

            expr_06.onFrameRateChange = (Action <float>) Delegate.Combine(expr_06.onFrameRateChange, new Action <float>(delegate(float newFrameRate)
            {
                this.m_CurveEditor.invSnap = newFrameRate;
                this.m_CurveEditor.hTicks.SetTickModulosForFrameRate(newFrameRate);
            }));
        }
 // Retrieve current value.  If bindings are available and value is animated, use bindings to get value.
 // Otherwise, evaluate AnimationWindowCurve at current time.
 public static object GetCurrentValue(AnimationWindowState state, AnimationWindowCurve curve)
 {
     if (state.previewing && curve.rootGameObject != null)
     {
         return(AnimationWindowUtility.GetCurrentValue(curve.rootGameObject, curve.binding));
     }
     else
     {
         return(curve.Evaluate(state.currentTime));
     }
 }
コード例 #8
0
ファイル: AnimEditor.cs プロジェクト: qipa/UnityDecompiled-2
        public void OnDisable()
        {
            AnimEditor.s_AnimationWindows.Remove(this);
            if (this.m_CurveEditor != null)
            {
                CurveEditor expr_1D = this.m_CurveEditor;
                expr_1D.curvesUpdated = (CurveEditor.CallbackFunction)Delegate.Remove(expr_1D.curvesUpdated, new CurveEditor.CallbackFunction(this.SaveChangedCurvesFromCurveEditor));
            }
            AnimationWindowState expr_44 = this.m_State;

            expr_44.onClipSelectionChanged = (Action)Delegate.Remove(expr_44.onClipSelectionChanged, new Action(this.OnClipSelectionChange));
            this.m_State.OnDisable();
        }
コード例 #9
0
ファイル: AnimEditor.cs プロジェクト: yaoya/UnityDecompiled
        private void InitializeNonserializedValues()
        {
            AnimationWindowState expr_07 = this.m_State;

            expr_07.onFrameRateChange = (Action <float>) Delegate.Combine(expr_07.onFrameRateChange, new Action <float>(delegate(float newFrameRate)
            {
                this.m_CurveEditor.invSnap = newFrameRate;
                this.m_CurveEditor.hTicks.SetTickModulosForFrameRate(newFrameRate);
            }));
            AnimationWindowState expr_2E = this.m_State;

            expr_2E.onStartLiveEdit = (Action)Delegate.Combine(expr_2E.onStartLiveEdit, new Action(this.OnStartLiveEdit));
            AnimationWindowState expr_55 = this.m_State;

            expr_55.onEndLiveEdit = (Action)Delegate.Combine(expr_55.onEndLiveEdit, new Action(this.OnEndLiveEdit));
        }
コード例 #10
0
        internal static bool ShowAtPosition(Rect buttonRect, AnimationWindowState state, OnNewCurveAdded newCurveCallback)
        {
            // We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time.
            long nowMilliSeconds = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
            bool justClosed      = nowMilliSeconds < s_LastClosedTime + 50;

            if (!justClosed)
            {
                Event.current.Use();
                if (s_AddCurvesPopup == null)
                {
                    s_AddCurvesPopup = ScriptableObject.CreateInstance <AddCurvesPopup>();
                }

                NewCurveAddedCallback = newCurveCallback;
                s_State = state;
                s_AddCurvesPopup.Init(buttonRect);
                return(true);
            }
            return(false);
        }
コード例 #11
0
 public void OnEnable()
 {
     this.hideFlags = HideFlags.HideAndDontSave;
     AnimEditor.s_AnimationWindows.Add(this);
     if ((UnityEngine.Object) this.m_State == (UnityEngine.Object)null)
     {
         this.m_State            = ScriptableObject.CreateInstance(typeof(AnimationWindowState)) as AnimationWindowState;
         this.m_State.hideFlags  = HideFlags.HideAndDontSave;
         this.m_State.animEditor = this;
         this.InitializeHorizontalSplitter();
         this.InitializeClipSelection();
         this.InitializeDopeSheet();
         this.InitializeEvents();
         this.InitializeCurveEditor();
     }
     this.InitializeNonserializedValues();
     this.m_State.timeArea  = !this.m_State.showCurveEditor ? (TimeArea)this.m_DopeSheet : (TimeArea)this.m_CurveEditor;
     this.m_DopeSheet.state = this.m_State;
     this.m_ClipPopup.state = this.m_State;
     this.m_State.onClipSelectionChanged += new System.Action(this.OnClipSelectionChange);
     this.m_State.OnSelectionChange();
     this.m_CurveEditor.curvesUpdated += new CurveEditor.CallbackFunction(this.SaveChangedCurvesFromCurveEditor);
 }
コード例 #12
0
        public void OnDisable()
        {
            AnimEditor.s_AnimationWindows.Remove(this);
            if (this.m_CurveEditor != null)
            {
                CurveEditor expr_1F = this.m_CurveEditor;
                expr_1F.curvesUpdated = (CurveEditor.CallbackFunction)Delegate.Remove(expr_1F.curvesUpdated, new CurveEditor.CallbackFunction(this.SaveChangedCurvesFromCurveEditor));
                this.m_CurveEditor.OnDisable();
            }
            if (this.m_DopeSheet != null)
            {
                this.m_DopeSheet.OnDisable();
            }
            AnimationWindowSelection expr_6D = this.m_State.selection;

            expr_6D.onSelectionChanged = (Action)Delegate.Remove(expr_6D.onSelectionChanged, new Action(this.OnSelectionChanged));
            AnimationWindowState expr_94 = this.m_State;

            expr_94.onStartLiveEdit = (Action)Delegate.Remove(expr_94.onStartLiveEdit, new Action(this.OnStartLiveEdit));
            AnimationWindowState expr_BB = this.m_State;

            expr_BB.onEndLiveEdit = (Action)Delegate.Remove(expr_BB.onEndLiveEdit, new Action(this.OnEndLiveEdit));
            this.m_State.OnDisable();
        }
コード例 #13
0
 public AnimationWindowHierarchyGUI(TreeViewController treeView, AnimationWindowState state)
     : base(treeView)
 {
     this.state = state;
     InitStyles();
 }
コード例 #14
0
        public void EventLineGUI(Rect rect, AnimationWindowState state)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            GUI.BeginGroup(rect);
            Color color = GUI.color;
            Rect  rect1 = new Rect(0.0f, 0.0f, rect.width, rect.height);
            float time  = (float)Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate) / state.frameRate;

            if ((UnityEngine.Object)activeAnimationClip != (UnityEngine.Object)null)
            {
                AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(activeAnimationClip);
                Texture          image           = EditorGUIUtility.IconContent("Animation.EventMarker").image;
                Rect[]           rectArray       = new Rect[animationEvents.Length];
                Rect[]           positions       = new Rect[animationEvents.Length];
                int num1 = 1;
                int num2 = 0;
                for (int index = 0; index < animationEvents.Length; ++index)
                {
                    AnimationEvent animationEvent = animationEvents[index];
                    if (num2 == 0)
                    {
                        num1 = 1;
                        while (index + num1 < animationEvents.Length && (double)animationEvents[index + num1].time == (double)animationEvent.time)
                        {
                            ++num1;
                        }
                        num2 = num1;
                    }
                    --num2;
                    float num3 = Mathf.Floor(state.FrameToPixel(animationEvent.time * activeAnimationClip.frameRate, rect));
                    int   num4 = 0;
                    if (num1 > 1)
                    {
                        num4 = Mathf.FloorToInt(Mathf.Max(0.0f, (float)Mathf.Min((num1 - 1) * (image.width - 1), (int)((double)state.FrameDeltaToPixel(rect) - (double)(image.width * 2))) - (float)((image.width - 1) * num2)));
                    }
                    Rect rect2 = new Rect(num3 + (float)num4 - (float)(image.width / 2), (rect.height - 10f) * (float)(num2 - num1 + 1) / (float)Mathf.Max(1, num1 - 1), (float)image.width, (float)image.height);
                    rectArray[index] = rect2;
                    positions[index] = rect2;
                }
                if (this.m_DirtyTooltip)
                {
                    if (this.m_HoverEvent >= 0 && this.m_HoverEvent < rectArray.Length)
                    {
                        this.m_InstantTooltipText  = AnimationEventPopup.FormatEvent(activeRootGameObject, animationEvents[this.m_HoverEvent]);
                        this.m_InstantTooltipPoint = new Vector2((float)((double)rectArray[this.m_HoverEvent].xMin + (double)(int)((double)rectArray[this.m_HoverEvent].width / 2.0) + (double)rect.x - 30.0), rect.yMax);
                    }
                    this.m_DirtyTooltip = false;
                }
                if (this.m_EventsSelected == null || this.m_EventsSelected.Length != animationEvents.Length)
                {
                    this.m_EventsSelected = new bool[animationEvents.Length];
                    AnimationEventPopup.ClosePopup();
                }
                Vector2 offset = Vector2.zero;
                int     clickedIndex;
                float   startSelect;
                float   endSelect;
                switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), rectArray, ref this.m_EventsSelected, (bool[])null, out clickedIndex, out offset, out startSelect, out endSelect, GUIStyle.none))
                {
                case HighLevelEvent.DoubleClick:
                    if (clickedIndex != -1)
                    {
                        AnimationEventPopup.Edit(activeRootGameObject, state.activeAnimationClip, clickedIndex, this.m_Owner);
                        break;
                    }
                    this.EventLineContextMenuAdd((object)new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1));
                    break;

                case HighLevelEvent.ContextClick:
                    GenericMenu genericMenu = new GenericMenu();
                    AnimationEventTimeLine.EventLineContextMenuObject contextMenuObject = new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, animationEvents[clickedIndex].time, clickedIndex);
                    genericMenu.AddItem(new GUIContent("Edit Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuEdit), (object)contextMenuObject);
                    genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), (object)contextMenuObject);
                    genericMenu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), (object)contextMenuObject);
                    genericMenu.ShowAsContext();
                    this.m_InstantTooltipText = (string)null;
                    this.m_DirtyTooltip       = true;
                    state.Repaint();
                    break;

                case HighLevelEvent.BeginDrag:
                    this.m_EventsAtMouseDown = animationEvents;
                    this.m_EventTimes        = new float[animationEvents.Length];
                    for (int index = 0; index < animationEvents.Length; ++index)
                    {
                        this.m_EventTimes[index] = animationEvents[index].time;
                    }
                    break;

                case HighLevelEvent.Drag:
                    for (int index = animationEvents.Length - 1; index >= 0; --index)
                    {
                        if (this.m_EventsSelected[index])
                        {
                            AnimationEvent animationEvent = this.m_EventsAtMouseDown[index];
                            animationEvent.time = this.m_EventTimes[index] + offset.x * state.PixelDeltaToTime(rect);
                            animationEvent.time = Mathf.Max(0.0f, animationEvent.time);
                            animationEvent.time = (float)Mathf.RoundToInt(animationEvent.time * activeAnimationClip.frameRate) / activeAnimationClip.frameRate;
                        }
                    }
                    int[] numArray1 = new int[this.m_EventsSelected.Length];
                    for (int index = 0; index < numArray1.Length; ++index)
                    {
                        numArray1[index] = index;
                    }
                    Array.Sort((Array)this.m_EventsAtMouseDown, (Array)numArray1, (IComparer) new AnimationEventTimeLine.EventComparer());
                    bool[]  flagArray = (bool[])this.m_EventsSelected.Clone();
                    float[] numArray2 = (float[])this.m_EventTimes.Clone();
                    for (int index = 0; index < numArray1.Length; ++index)
                    {
                        this.m_EventsSelected[index] = flagArray[numArray1[index]];
                        this.m_EventTimes[index]     = numArray2[numArray1[index]];
                    }
                    Undo.RegisterCompleteObjectUndo((UnityEngine.Object)activeAnimationClip, "Move Event");
                    AnimationUtility.SetAnimationEvents(activeAnimationClip, this.m_EventsAtMouseDown);
                    this.m_DirtyTooltip = true;
                    break;

                case HighLevelEvent.Delete:
                    this.DeleteEvents(activeAnimationClip, this.m_EventsSelected);
                    break;

                case HighLevelEvent.SelectionChanged:
                    state.ClearKeySelections();
                    if (clickedIndex != -1)
                    {
                        AnimationEventPopup.UpdateSelection(activeRootGameObject, state.activeAnimationClip, clickedIndex, this.m_Owner);
                        break;
                    }
                    break;
                }
                this.CheckRectsOnMouseMove(rect, animationEvents, rectArray);
            }
            if (Event.current.type == EventType.ContextClick && rect1.Contains(Event.current.mousePosition))
            {
                Event.current.Use();
                GenericMenu genericMenu = new GenericMenu();
                genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), (object)new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1));
                genericMenu.ShowAsContext();
            }
            GUI.color = color;
            GUI.EndGroup();
        }
コード例 #15
0
 public void Init(TimelineWindow window, AnimationWindowState state, TimelineClip clip)
 {
     this.m_Clip            = clip;
     this.m_AnimWindowState = state;
 }
コード例 #16
0
 public void Init(TimelineWindow window, AnimationWindowState state, TimelineWindowTimeControl.ClipData clip)
 {
     this.m_ClipData        = clip;
     this.m_AnimWindowState = state;
 }
コード例 #17
0
 public override void Initialize(TimeArea timeArea)
 {
     base.Initialize(timeArea);
     this.m_DopeSheetEditor = (timeArea as DopeSheetEditor);
     this.m_State           = this.m_DopeSheetEditor.state;
     if (this.m_SelectionBoxes == null)
     {
         this.m_SelectionBoxes = new AreaManipulator[2];
         for (int i = 0; i < 2; i++)
         {
             this.m_SelectionBoxes[i] = new AreaManipulator(base.styles.rectangleToolSelection, MouseCursor.MoveArrow);
             AreaManipulator expr_66 = this.m_SelectionBoxes[i];
             expr_66.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_66.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
             {
                 bool result;
                 if (!evt.shift && !EditorGUI.actionKey && this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
                 {
                     this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                     result = true;
                 }
                 else
                 {
                     result = false;
                 }
                 return(result);
             }));
             AreaManipulator expr_8F = this.m_SelectionBoxes[i];
             expr_8F.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_8F.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
             {
                 this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f));
                 return(true);
             }));
             AreaManipulator expr_B8 = this.m_SelectionBoxes[i];
             expr_B8.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_B8.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
             {
                 this.OnEndMove();
                 return(true);
             }));
         }
     }
     if (this.m_SelectionScaleLeft == null)
     {
         this.m_SelectionScaleLeft = new AreaManipulator(base.styles.dopesheetScaleLeft, MouseCursor.ResizeHorizontal);
         AreaManipulator expr_10F = this.m_SelectionScaleLeft;
         expr_10F.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_10F.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_136 = this.m_SelectionScaleLeft;
         expr_136.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_136.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         }));
         AreaManipulator expr_15D = this.m_SelectionScaleLeft;
         expr_15D.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_15D.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
     if (this.m_SelectionScaleRight == null)
     {
         this.m_SelectionScaleRight = new AreaManipulator(base.styles.dopesheetScaleRight, MouseCursor.ResizeHorizontal);
         AreaManipulator expr_1A8 = this.m_SelectionScaleRight;
         expr_1A8.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(expr_1A8.onStartDrag, new AnimationWindowManipulator.OnStartDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             bool result;
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 result = true;
             }
             else
             {
                 result = false;
             }
             return(result);
         }));
         AreaManipulator expr_1CF = this.m_SelectionScaleRight;
         expr_1CF.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(expr_1CF.onDrag, new AnimationWindowManipulator.OnDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         }));
         AreaManipulator expr_1F6 = this.m_SelectionScaleRight;
         expr_1F6.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(expr_1F6.onEndDrag, new AnimationWindowManipulator.OnEndDragDelegate(delegate(AnimationWindowManipulator manipulator, Event evt)
         {
             this.OnEndScale();
             return(true);
         }));
     }
 }
コード例 #18
0
 public AnimationWindowHierarchyDataSource(TreeViewController treeView, AnimationWindowState animationWindowState)
     : base(treeView)
 {
     state = animationWindowState;
 }
コード例 #19
0
 public void Init(AnimationWindowState animState, TimelineClip clip)
 {
     m_Clip            = clip;
     m_AnimWindowState = animState;
 }
コード例 #20
0
 public CandidateRecordingState(AnimationWindowState state, AnimationClip candidateClip)
 {
     activeGameObject     = state.activeGameObject;
     activeRootGameObject = state.activeRootGameObject;
     activeAnimationClip  = candidateClip;
 }
コード例 #21
0
 public override void Initialize(TimeArea timeArea)
 {
     base.Initialize(timeArea);
     this.m_DopeSheetEditor = timeArea as DopeSheetEditor;
     this.m_State           = this.m_DopeSheetEditor.state;
     if (this.m_SelectionBoxes == null)
     {
         this.m_SelectionBoxes = new AreaManipulator[2];
         for (int i = 0; i < 2; i++)
         {
             this.m_SelectionBoxes[i] = new AreaManipulator(base.styles.rectangleToolSelection, MouseCursor.MoveArrow);
             AreaManipulator manipulator1 = this.m_SelectionBoxes[i];
             manipulator1.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(manipulator1.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
                 if ((!(evt.shift || EditorGUI.actionKey) && this.hasSelection) && manipulator.rect.Contains(evt.mousePosition))
                 {
                     this.OnStartMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                     return(true);
                 }
                 return(false);
             });
             AreaManipulator manipulator2 = this.m_SelectionBoxes[i];
             manipulator2.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(manipulator2.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
                 this.OnMove(new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f));
                 return(true);
             });
             AreaManipulator manipulator3 = this.m_SelectionBoxes[i];
             manipulator3.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(manipulator3.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
                 this.OnEndMove();
                 return(true);
             });
         }
     }
     if (this.m_SelectionScaleLeft == null)
     {
         this.m_SelectionScaleLeft             = new AreaManipulator(base.styles.dopesheetScaleLeft, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleLeft.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Right, RectangleTool.ToolCoord.Left, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_SelectionScaleLeft.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         });
         this.m_SelectionScaleLeft.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleLeft.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
     if (this.m_SelectionScaleRight == null)
     {
         this.m_SelectionScaleRight             = new AreaManipulator(base.styles.dopesheetScaleRight, MouseCursor.ResizeHorizontal);
         this.m_SelectionScaleRight.onStartDrag = (AnimationWindowManipulator.OnStartDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onStartDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             if (this.hasSelection && manipulator.rect.Contains(evt.mousePosition))
             {
                 this.OnStartScale(RectangleTool.ToolCoord.Left, RectangleTool.ToolCoord.Right, new Vector2(base.PixelToTime(evt.mousePosition.x, this.frameRate), 0f), base.rippleTimeClutch);
                 return(true);
             }
             return(false);
         });
         this.m_SelectionScaleRight.onDrag = (AnimationWindowManipulator.OnDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnScaleTime(base.PixelToTime(evt.mousePosition.x, this.frameRate));
             return(true);
         });
         this.m_SelectionScaleRight.onEndDrag = (AnimationWindowManipulator.OnEndDragDelegate) Delegate.Combine(this.m_SelectionScaleRight.onEndDrag, delegate(AnimationWindowManipulator manipulator, Event evt) {
             this.OnEndScale();
             return(true);
         });
     }
 }
コード例 #22
0
        public void EventLineGUI(Rect rect, AnimationWindowState state)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            GUI.BeginGroup(rect);
            Color color = GUI.color;
            Rect  rect2 = new Rect(0f, 0f, rect.width, rect.height);
            float time  = ((float)Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate)) / state.frameRate;

            if (activeAnimationClip != null)
            {
                int              num8;
                float            num9;
                float            num10;
                AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(activeAnimationClip);
                Texture          image           = EditorGUIUtility.IconContent("Animation.EventMarker").image;
                Rect[]           hitPositions    = new Rect[animationEvents.Length];
                Rect[]           positions       = new Rect[animationEvents.Length];
                int              num2            = 1;
                int              num3            = 0;
                for (int i = 0; i < animationEvents.Length; i++)
                {
                    AnimationEvent event2 = animationEvents[i];
                    if (num3 == 0)
                    {
                        num2 = 1;
                        while (((i + num2) < animationEvents.Length) && (animationEvents[i + num2].time == event2.time))
                        {
                            num2++;
                        }
                        num3 = num2;
                    }
                    num3--;
                    float num5 = Mathf.Floor(state.FrameToPixel(event2.time * activeAnimationClip.frameRate, rect));
                    int   num6 = 0;
                    if (num2 > 1)
                    {
                        float num7 = Mathf.Min((int)((num2 - 1) * (image.width - 1)), (int)(((int)state.FrameDeltaToPixel(rect)) - (image.width * 2)));
                        num6 = Mathf.FloorToInt(Mathf.Max((float)0f, (float)(num7 - ((image.width - 1) * num3))));
                    }
                    Rect rect3 = new Rect((num5 + num6) - (image.width / 2), ((rect.height - 10f) * ((num3 - num2) + 1)) / ((float)Mathf.Max(1, num2 - 1)), (float)image.width, (float)image.height);
                    hitPositions[i] = rect3;
                    positions[i]    = rect3;
                }
                if (this.m_DirtyTooltip)
                {
                    if ((this.m_HoverEvent >= 0) && (this.m_HoverEvent < hitPositions.Length))
                    {
                        this.m_InstantTooltipText  = AnimationEventPopup.FormatEvent(activeRootGameObject, animationEvents[this.m_HoverEvent]);
                        this.m_InstantTooltipPoint = new Vector2(((hitPositions[this.m_HoverEvent].xMin + ((int)(hitPositions[this.m_HoverEvent].width / 2f))) + rect.x) - 30f, rect.yMax);
                    }
                    this.m_DirtyTooltip = false;
                }
                if ((this.m_EventsSelected == null) || (this.m_EventsSelected.Length != animationEvents.Length))
                {
                    this.m_EventsSelected = new bool[animationEvents.Length];
                    AnimationEventPopup.ClosePopup();
                }
                Vector2 zero = Vector2.zero;
                switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), hitPositions, ref this.m_EventsSelected, null, out num8, out zero, out num9, out num10, GUIStyle.none))
                {
                case HighLevelEvent.DoubleClick:
                    if (num8 == -1)
                    {
                        this.EventLineContextMenuAdd(new EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1));
                        break;
                    }
                    AnimationEventPopup.Edit(activeRootGameObject, state.activeAnimationClip, num8, this.m_Owner);
                    break;

                case HighLevelEvent.ContextClick:
                {
                    GenericMenu menu = new GenericMenu();
                    EventLineContextMenuObject userData = new EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, animationEvents[num8].time, num8);
                    menu.AddItem(new GUIContent("Edit Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuEdit), userData);
                    menu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), userData);
                    menu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), userData);
                    menu.ShowAsContext();
                    this.m_InstantTooltipText = null;
                    this.m_DirtyTooltip       = true;
                    state.Repaint();
                    break;
                }

                case HighLevelEvent.BeginDrag:
                    this.m_EventsAtMouseDown = animationEvents;
                    this.m_EventTimes        = new float[animationEvents.Length];
                    for (int j = 0; j < animationEvents.Length; j++)
                    {
                        this.m_EventTimes[j] = animationEvents[j].time;
                    }
                    break;

                case HighLevelEvent.Drag:
                {
                    for (int k = animationEvents.Length - 1; k >= 0; k--)
                    {
                        if (this.m_EventsSelected[k])
                        {
                            AnimationEvent event4 = this.m_EventsAtMouseDown[k];
                            event4.time = this.m_EventTimes[k] + (zero.x * state.PixelDeltaToTime(rect));
                            event4.time = Mathf.Max(0f, event4.time);
                            event4.time = ((float)Mathf.RoundToInt(event4.time * activeAnimationClip.frameRate)) / activeAnimationClip.frameRate;
                        }
                    }
                    int[] items = new int[this.m_EventsSelected.Length];
                    for (int m = 0; m < items.Length; m++)
                    {
                        items[m] = m;
                    }
                    Array.Sort(this.m_EventsAtMouseDown, items, new EventComparer());
                    bool[]  flagArray = (bool[])this.m_EventsSelected.Clone();
                    float[] numArray2 = (float[])this.m_EventTimes.Clone();
                    for (int n = 0; n < items.Length; n++)
                    {
                        this.m_EventsSelected[n] = flagArray[items[n]];
                        this.m_EventTimes[n]     = numArray2[items[n]];
                    }
                    Undo.RegisterCompleteObjectUndo(activeAnimationClip, "Move Event");
                    AnimationUtility.SetAnimationEvents(activeAnimationClip, this.m_EventsAtMouseDown);
                    this.m_DirtyTooltip = true;
                    break;
                }

                case HighLevelEvent.Delete:
                    this.DeleteEvents(activeAnimationClip, this.m_EventsSelected);
                    break;

                case HighLevelEvent.SelectionChanged:
                    state.ClearKeySelections();
                    if (num8 != -1)
                    {
                        AnimationEventPopup.UpdateSelection(activeRootGameObject, state.activeAnimationClip, num8, this.m_Owner);
                    }
                    break;
                }
                this.CheckRectsOnMouseMove(rect, animationEvents, hitPositions);
            }
            if ((Event.current.type == EventType.ContextClick) && rect2.Contains(Event.current.mousePosition))
            {
                Event.current.Use();
                GenericMenu menu2 = new GenericMenu();
                menu2.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1));
                menu2.ShowAsContext();
            }
            GUI.color = color;
            GUI.EndGroup();
        }
コード例 #23
0
        public void EventLineGUI(Rect rect, AnimationWindowState state)
        {
            AnimationClip activeAnimationClip  = state.activeAnimationClip;
            GameObject    activeRootGameObject = state.activeRootGameObject;

            if (activeRootGameObject == null)
            {
                return;
            }
            GUI.BeginGroup(rect);
            Color color = GUI.color;
            Rect  rect2 = new Rect(0f, 0f, rect.width, rect.height);
            float time  = Mathf.Max((float)Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate) / state.frameRate, 0f);

            if (activeAnimationClip != null)
            {
                AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(activeAnimationClip);
                Texture          image           = EditorGUIUtility.IconContent("Animation.EventMarker").image;
                Rect[]           array           = new Rect[animationEvents.Length];
                Rect[]           array2          = new Rect[animationEvents.Length];
                int num  = 1;
                int num2 = 0;
                for (int i = 0; i < animationEvents.Length; i++)
                {
                    AnimationEvent animationEvent = animationEvents[i];
                    if (num2 == 0)
                    {
                        num = 1;
                        while (i + num < animationEvents.Length && animationEvents[i + num].time == animationEvent.time)
                        {
                            num++;
                        }
                        num2 = num;
                    }
                    num2--;
                    float num3 = Mathf.Floor(state.FrameToPixel(animationEvent.time * activeAnimationClip.frameRate, rect));
                    int   num4 = 0;
                    if (num > 1)
                    {
                        float num5 = (float)Mathf.Min((num - 1) * (image.width - 1), (int)(state.FrameDeltaToPixel(rect) - (float)(image.width * 2)));
                        num4 = Mathf.FloorToInt(Mathf.Max(0f, num5 - (float)((image.width - 1) * num2)));
                    }
                    Rect rect3 = new Rect(num3 + (float)num4 - (float)(image.width / 2), (rect.height - 10f) * (float)(num2 - num + 1) / (float)Mathf.Max(1, num - 1), (float)image.width, (float)image.height);
                    array[i]  = rect3;
                    array2[i] = rect3;
                }
                if (this.m_DirtyTooltip)
                {
                    if (this.m_HoverEvent >= 0 && this.m_HoverEvent < array.Length)
                    {
                        this.m_InstantTooltipText  = AnimationEventPopup.FormatEvent(activeRootGameObject, animationEvents[this.m_HoverEvent]);
                        this.m_InstantTooltipPoint = new Vector2(array[this.m_HoverEvent].xMin + (float)((int)(array[this.m_HoverEvent].width / 2f)) + rect.x - 30f, rect.yMax);
                    }
                    this.m_DirtyTooltip = false;
                }
                if (this.m_EventsSelected == null || this.m_EventsSelected.Length != animationEvents.Length)
                {
                    this.m_EventsSelected = new bool[animationEvents.Length];
                    AnimationEventPopup.ClosePopup();
                }
                Vector2        zero = Vector2.zero;
                int            num6;
                float          num7;
                float          num8;
                HighLevelEvent highLevelEvent = EditorGUIExt.MultiSelection(rect, array2, new GUIContent(image), array, ref this.m_EventsSelected, null, out num6, out zero, out num7, out num8, GUIStyle.none);
                if (highLevelEvent != HighLevelEvent.None)
                {
                    switch (highLevelEvent)
                    {
                    case HighLevelEvent.DoubleClick:
                        if (num6 != -1)
                        {
                            AnimationEventPopup.Edit(activeRootGameObject, state.activeAnimationClip, num6, this.m_Owner);
                        }
                        else
                        {
                            this.EventLineContextMenuAdd(new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1));
                        }
                        break;

                    case HighLevelEvent.ContextClick:
                    {
                        GenericMenu genericMenu = new GenericMenu();
                        AnimationEventTimeLine.EventLineContextMenuObject userData = new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, animationEvents[num6].time, num6);
                        genericMenu.AddItem(new GUIContent("Edit Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuEdit), userData);
                        genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), userData);
                        genericMenu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), userData);
                        genericMenu.ShowAsContext();
                        this.m_InstantTooltipText = null;
                        this.m_DirtyTooltip       = true;
                        state.Repaint();
                        break;
                    }

                    case HighLevelEvent.BeginDrag:
                        this.m_EventsAtMouseDown = animationEvents;
                        this.m_EventTimes        = new float[animationEvents.Length];
                        for (int j = 0; j < animationEvents.Length; j++)
                        {
                            this.m_EventTimes[j] = animationEvents[j].time;
                        }
                        break;

                    case HighLevelEvent.Drag:
                    {
                        for (int k = animationEvents.Length - 1; k >= 0; k--)
                        {
                            if (this.m_EventsSelected[k])
                            {
                                AnimationEvent animationEvent2 = this.m_EventsAtMouseDown[k];
                                animationEvent2.time = this.m_EventTimes[k] + zero.x * state.PixelDeltaToTime(rect);
                                animationEvent2.time = Mathf.Max(0f, animationEvent2.time);
                                animationEvent2.time = (float)Mathf.RoundToInt(animationEvent2.time * activeAnimationClip.frameRate) / activeAnimationClip.frameRate;
                            }
                        }
                        int[] array3 = new int[this.m_EventsSelected.Length];
                        for (int l = 0; l < array3.Length; l++)
                        {
                            array3[l] = l;
                        }
                        Array.Sort(this.m_EventsAtMouseDown, array3, new AnimationEventTimeLine.EventComparer());
                        bool[]  array4 = (bool[])this.m_EventsSelected.Clone();
                        float[] array5 = (float[])this.m_EventTimes.Clone();
                        for (int m = 0; m < array3.Length; m++)
                        {
                            this.m_EventsSelected[m] = array4[array3[m]];
                            this.m_EventTimes[m]     = array5[array3[m]];
                        }
                        Undo.RegisterCompleteObjectUndo(activeAnimationClip, "Move Event");
                        AnimationUtility.SetAnimationEvents(activeAnimationClip, this.m_EventsAtMouseDown);
                        this.m_DirtyTooltip = true;
                        break;
                    }

                    case HighLevelEvent.Delete:
                        this.DeleteEvents(activeAnimationClip, this.m_EventsSelected);
                        break;

                    case HighLevelEvent.SelectionChanged:
                        state.ClearKeySelections();
                        if (num6 != -1)
                        {
                            AnimationEventPopup.UpdateSelection(activeRootGameObject, state.activeAnimationClip, num6, this.m_Owner);
                        }
                        break;
                    }
                }
                this.CheckRectsOnMouseMove(rect, animationEvents, array);
            }
            if (Event.current.type == EventType.ContextClick && rect2.Contains(Event.current.mousePosition))
            {
                Event.current.Use();
                GenericMenu genericMenu2 = new GenericMenu();
                genericMenu2.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1));
                genericMenu2.ShowAsContext();
            }
            GUI.color = color;
            GUI.EndGroup();
        }
        public override void Initialize(TimeArea timeArea)
        {
            base.Initialize(timeArea);
            m_DopeSheetEditor = timeArea as DopeSheetEditor;
            m_State           = m_DopeSheetEditor.state;

            if (m_SelectionBoxes == null)
            {
                m_SelectionBoxes = new AreaManipulator[2];

                for (int i = 0; i < 2; ++i)
                {
                    m_SelectionBoxes[i] = new AreaManipulator(styles.rectangleToolSelection, MouseCursor.MoveArrow);

                    m_SelectionBoxes[i].onStartDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                        bool curveEditorOverride = evt.shift || EditorGUI.actionKey;
                        if (!curveEditorOverride && hasSelection && manipulator.rect.Contains(evt.mousePosition))
                        {
                            OnStartMove(new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0.0f), rippleTime);
                            return(true);
                        }

                        return(false);
                    };
                    m_SelectionBoxes[i].onDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                        OnMove(new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0.0f));
                        return(true);
                    };
                    m_SelectionBoxes[i].onEndDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                        OnEndMove();
                        return(true);
                    };
                }
            }

            if (m_SelectionScaleLeft == null)
            {
                m_SelectionScaleLeft = new AreaManipulator(styles.dopesheetScaleLeft, MouseCursor.ResizeHorizontal);

                m_SelectionScaleLeft.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Right, ToolCoord.Left, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), false);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionScaleLeft.onDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_SelectionScaleLeft.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_SelectionScaleRight == null)
            {
                m_SelectionScaleRight = new AreaManipulator(styles.dopesheetScaleRight, MouseCursor.ResizeHorizontal);

                m_SelectionScaleRight.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Left, ToolCoord.Right, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), false);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionScaleRight.onDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_SelectionScaleRight.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_SelectionRippleLeft == null)
            {
                m_SelectionRippleLeft = new AreaManipulator(styles.dopesheetRippleLeft, MouseCursor.ResizeHorizontal);

                m_SelectionRippleLeft.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Right, ToolCoord.Left, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), true);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionRippleLeft.onDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_SelectionRippleLeft.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    OnEndScale();
                    return(true);
                };
            }

            if (m_SelectionRippleRight == null)
            {
                m_SelectionRippleRight = new AreaManipulator(styles.dopesheetRippleRight, MouseCursor.ResizeHorizontal);

                m_SelectionRippleRight.onStartDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    if (hasSelection && manipulator.rect.Contains(evt.mousePosition))
                    {
                        OnStartScale(ToolCoord.Left, ToolCoord.Right, new Vector2(PixelToTime(evt.mousePosition.x, frameRate), 0f), true);
                        return(true);
                    }

                    return(false);
                };
                m_SelectionRippleRight.onDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    OnScaleTime(PixelToTime(evt.mousePosition.x, frameRate));
                    return(true);
                };
                m_SelectionRippleRight.onEndDrag += (AnimationWindowManipulator manipulator, Event evt) => {
                    OnEndScale();
                    return(true);
                };
            }
        }
コード例 #25
0
 public RecordingState(AnimationWindowState state, RecordingStateMode mode)
 {
     m_State = state;
     m_Mode  = mode;
 }
コード例 #26
0
 public void Init(AnimationWindowState animState, ClipData clip)
 {
     m_ClipData        = clip;
     m_AnimWindowState = animState;
 }
 public AnimationWindowHierarchy(AnimationWindowState state, EditorWindow owner, Rect position)
 {
     m_State = state;
     Init(owner, position);
 }
コード例 #28
0
        public void EventLineGUI(Rect rect, AnimationWindowState state)
        {
            //  We only display and manipulate animation events from the main
            //  game object in selection.  If we ever want to update to handle
            //  a multiple selection, a single timeline might not be sufficient...
            AnimationClip clip     = state.activeAnimationClip;
            GameObject    animated = state.activeRootGameObject;

            GUI.BeginGroup(rect);
            Color backupCol = GUI.color;

            Rect eventLineRect = new Rect(0, 0, rect.width, rect.height);

            float mousePosTime = Mathf.Max(Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate) / state.frameRate, 0.0f);

            // Draw events
            if (clip != null)
            {
                AnimationEvent[] events      = AnimationUtility.GetAnimationEvents(clip);
                Texture          eventMarker = EditorGUIUtility.IconContent("Animation.EventMarker").image;

                // Calculate rects
                Rect[] hitRects   = new Rect[events.Length];
                Rect[] drawRects  = new Rect[events.Length];
                int    shared     = 1;
                int    sharedLeft = 0;
                for (int i = 0; i < events.Length; i++)
                {
                    AnimationEvent evt = events[i];

                    if (sharedLeft == 0)
                    {
                        shared = 1;
                        while (i + shared < events.Length && events[i + shared].time == evt.time)
                        {
                            shared++;
                        }
                        sharedLeft = shared;
                    }
                    sharedLeft--;

                    // Important to take floor of positions of GUI stuff to get pixel correct alignment of
                    // stuff drawn with both GUI and Handles/GL. Otherwise things are off by one pixel half the time.
                    float keypos       = Mathf.Floor(state.FrameToPixel(evt.time * clip.frameRate, rect));
                    int   sharedOffset = 0;
                    if (shared > 1)
                    {
                        float spread = Mathf.Min((shared - 1) * (eventMarker.width - 1), (int)(state.FrameDeltaToPixel(rect) - eventMarker.width * 2));
                        sharedOffset = Mathf.FloorToInt(Mathf.Max(0, spread - (eventMarker.width - 1) * (sharedLeft)));
                    }

                    Rect r = new Rect(
                        keypos + sharedOffset - eventMarker.width / 2,
                        (rect.height - 10) * (float)(sharedLeft - shared + 1) / Mathf.Max(1, shared - 1),
                        eventMarker.width,
                        eventMarker.height);

                    hitRects[i]  = r;
                    drawRects[i] = r;
                }

                // Store tooptip info
                if (m_DirtyTooltip)
                {
                    if (m_HoverEvent >= 0 && m_HoverEvent < hitRects.Length)
                    {
                        m_InstantTooltipText  = AnimationWindowEventInspector.FormatEvent(animated, events[m_HoverEvent]);
                        m_InstantTooltipPoint = new Vector2(hitRects[m_HoverEvent].xMin + (int)(hitRects[m_HoverEvent].width / 2) + rect.x - 30, rect.yMax);
                    }
                    m_DirtyTooltip = false;
                }

                bool[] selectedEvents = new bool[events.Length];

                Object[] selectedObjects = Selection.objects;
                foreach (Object selectedObject in selectedObjects)
                {
                    AnimationWindowEvent awe = selectedObject as AnimationWindowEvent;
                    if (awe != null)
                    {
                        if (awe.eventIndex >= 0 && awe.eventIndex < selectedEvents.Length)
                        {
                            selectedEvents[awe.eventIndex] = true;
                        }
                    }
                }

                Vector2 offset = Vector2.zero;
                int     clickedIndex;
                float   startSelection, endSelection;

                // TODO: GUIStyle.none has hopping margins that need to be fixed
                HighLevelEvent hEvent = EditorGUIExt.MultiSelection(
                    rect,
                    drawRects,
                    new GUIContent(eventMarker),
                    hitRects,
                    ref selectedEvents,
                    null,
                    out clickedIndex,
                    out offset,
                    out startSelection,
                    out endSelection,
                    GUIStyle.none
                    );

                if (hEvent != HighLevelEvent.None)
                {
                    switch (hEvent)
                    {
                    case HighLevelEvent.BeginDrag:
                        m_EventsAtMouseDown = events;
                        m_EventTimes        = new float[events.Length];
                        for (int i = 0; i < events.Length; i++)
                        {
                            m_EventTimes[i] = events[i].time;
                        }
                        break;

                    case HighLevelEvent.SelectionChanged:
                        state.ClearKeySelections();
                        EditEvents(animated, clip, selectedEvents);
                        break;

                    case HighLevelEvent.Delete:
                        DeleteEvents(clip, selectedEvents);
                        break;

                    case HighLevelEvent.DoubleClick:

                        if (clickedIndex != -1)
                        {
                            EditEvents(animated, clip, selectedEvents);
                        }
                        else
                        {
                            EventLineContextMenuAdd(new EventLineContextMenuObject(animated, clip, mousePosTime, -1, selectedEvents));
                        }
                        break;

                    case HighLevelEvent.Drag:
                        for (int i = events.Length - 1; i >= 0; i--)
                        {
                            if (selectedEvents[i])
                            {
                                AnimationEvent evt = m_EventsAtMouseDown[i];
                                evt.time = m_EventTimes[i] + offset.x * state.PixelDeltaToTime(rect);
                                evt.time = Mathf.Max(0.0F, evt.time);
                                evt.time = Mathf.RoundToInt(evt.time * clip.frameRate) / clip.frameRate;
                            }
                        }
                        int[] order = new int[selectedEvents.Length];
                        for (int i = 0; i < order.Length; i++)
                        {
                            order[i] = i;
                        }
                        System.Array.Sort(m_EventsAtMouseDown, order, new EventComparer());
                        bool[]  selectedOld = (bool[])selectedEvents.Clone();
                        float[] timesOld    = (float[])m_EventTimes.Clone();
                        for (int i = 0; i < order.Length; i++)
                        {
                            selectedEvents[i] = selectedOld[order[i]];
                            m_EventTimes[i]   = timesOld[order[i]];
                        }

                        // Update selection to reflect new order.
                        EditEvents(animated, clip, selectedEvents);

                        Undo.RegisterCompleteObjectUndo(clip, "Move Event");
                        AnimationUtility.SetAnimationEvents(clip, m_EventsAtMouseDown);
                        m_DirtyTooltip = true;
                        break;

                    case HighLevelEvent.ContextClick:
                        GenericMenu menu                = new GenericMenu();
                        var         contextData         = new EventLineContextMenuObject(animated, clip, events[clickedIndex].time, clickedIndex, selectedEvents);
                        int         selectedEventsCount = selectedEvents.Count(selected => selected);

                        menu.AddItem(
                            EditorGUIUtility.TrTextContent("Add Animation Event"),
                            false,
                            EventLineContextMenuAdd,
                            contextData);
                        menu.AddItem(
                            new GUIContent(selectedEventsCount > 1 ? "Delete Animation Events" : "Delete Animation Event"),
                            false,
                            EventLineContextMenuDelete,
                            contextData);
                        menu.ShowAsContext();

                        // Mouse may move while context menu is open - make sure instant tooltip is handled
                        m_InstantTooltipText = null;
                        m_DirtyTooltip       = true;
                        state.Repaint();
                        break;
                    }
                }

                CheckRectsOnMouseMove(rect, events, hitRects);

                // Create context menu on context click
                if (Event.current.type == EventType.ContextClick && eventLineRect.Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    // Create menu
                    GenericMenu menu                = new GenericMenu();
                    var         contextData         = new EventLineContextMenuObject(animated, clip, mousePosTime, -1, selectedEvents);
                    int         selectedEventsCount = selectedEvents.Count(selected => selected);

                    menu.AddItem(
                        EditorGUIUtility.TrTextContent("Add Animation Event"),
                        false,
                        EventLineContextMenuAdd,
                        contextData);

                    if (selectedEventsCount > 0)
                    {
                        menu.AddItem(
                            new GUIContent(selectedEventsCount > 1 ? "Delete Animation Events" : "Delete Animation Event"),
                            false,
                            EventLineContextMenuDelete,
                            contextData);
                    }

                    menu.ShowAsContext();
                }
            }

            GUI.color = backupCol;
            GUI.EndGroup();
        }
コード例 #29
0
ファイル: DopeSheetEditor.cs プロジェクト: demelev/projectHL
 public void OnGUI(AnimationWindowState state, AnimationWindowKeyframe keyframe)
 {
     if (!keyframe.isPPtrCurve)
     {
         this.backgroundRect = this.position;
         this.backgroundRect.x = (state.TimeToPixel(keyframe.time) + this.position.x) - (s_width / 2);
         this.backgroundRect.y += 16f;
         this.backgroundRect.width = s_width;
         this.backgroundRect.height = s_height;
         Rect backgroundRect = this.backgroundRect;
         backgroundRect.height = 16f;
         Rect position = this.backgroundRect;
         position.y += 16f;
         position.height = s_width;
         GUI.Box(this.backgroundRect, string.Empty);
         GUI.Box(position, AssetPreview.GetAssetPreview((UnityEngine.Object) keyframe.value));
         EditorGUI.BeginChangeCheck();
         UnityEngine.Object obj2 = EditorGUI.ObjectField(backgroundRect, (UnityEngine.Object) keyframe.value, keyframe.curve.m_ValueType, false);
         if (EditorGUI.EndChangeCheck())
         {
             keyframe.value = obj2;
             state.SaveCurve(keyframe.curve);
         }
     }
 }