예제 #1
0
 private void updateScrubber()
 {
     if (Event.current.type == EventType.Repaint && (InPreviewMode || cutscene.IsPlaying))
     {
         float num       = directorState.TimeToPosition(cutscene.RunningTime) + trackBodyBackground.x;
         Color arg_15A_0 = GUI.color;
         GUI.color     = new Color(1f, 0f, 0f, 1f);
         Handles.color = new Color(1f, 0f, 0f, 1f);
         if (num > trackBodyBackground.x && num < bodyArea.width)
         {
             GUI.DrawTexture(new Rect(num - 8f, 20f, 16f, 16f), scrubHead);
             Handles.DrawLine(new Vector2(num, 34f), new Vector2(num, timeRuleArea.y + trackBodyBackgroundNoVerticalScrollbar.height + 3f));
             Handles.DrawLine(new Vector2(num + 1f, 34f), new Vector2(num + 1f, timeRuleArea.y + trackBodyBackgroundNoVerticalScrollbar.height + 3f));
         }
         GUI.color = arg_15A_0;
     }
 }
예제 #2
0
    public override void HandleInput(DirectorControlState state, Rect trackPosition)
    {
        CinemaActionFixedWrapper wrapper = base.Wrapper as CinemaActionFixedWrapper;

        if (wrapper == null)
        {
            return;
        }
        if (base.isRenaming)
        {
            return;
        }
        float num  = state.TimeToPosition(wrapper.Firetime);
        float num2 = state.TimeToPosition(wrapper.Firetime + wrapper.Duration);

        base.controlPosition = new Rect(num, 0f, num2 - num, trackPosition.height);
        bool  flag1 = this.controlPosition.width < 15f;
        float num3  = flag1 ? 0f : 5f;
        Rect  rect  = new Rect(num, 0f, num3, trackPosition.height);
        Rect  rect2 = new Rect(num + num3, 0f, (num2 - num) - (2f * num3), trackPosition.height);
        Rect  rect3 = new Rect(num2 - num3, 0f, num3, trackPosition.height);

        EditorGUIUtility.AddCursorRect(rect2, MouseCursor.SlideArrow);
        if (!flag1)
        {
            EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeHorizontal);
            EditorGUIUtility.AddCursorRect(rect3, MouseCursor.ResizeHorizontal);
        }
        base.controlID = GUIUtility.GetControlID(wrapper.Behaviour.GetInstanceID(), UnityEngine.FocusType.Passive, base.controlPosition);
        int num4 = GUIUtility.GetControlID(wrapper.Behaviour.GetInstanceID(), FocusType.Passive, rect);
        int num5 = GUIUtility.GetControlID(wrapper.Behaviour.GetInstanceID(), FocusType.Passive, rect2);
        int num6 = GUIUtility.GetControlID(wrapper.Behaviour.GetInstanceID(), FocusType.Passive, rect3);

        if (((Event.current.GetTypeForControl(base.controlID) == EventType.MouseDown) && rect2.Contains(Event.current.mousePosition)) && (Event.current.button == 1))
        {
            if (!base.IsSelected)
            {
                GameObject[] objArray = Selection.gameObjects;
                ArrayUtility.Add <GameObject>(ref objArray, base.Wrapper.Behaviour.gameObject);
                Selection.objects        = objArray;
                base.hasSelectionChanged = true;
            }
            this.showContextMenu(wrapper.Behaviour);
            if (!base.TrackControl.TargetTrack.IsLocked)
            {
                Event.current.Use();
            }
        }
        switch (Event.current.GetTypeForControl(num5))
        {
        case 0:
        {
            if (!rect2.Contains(Event.current.mousePosition) || (Event.current.button != 0))
            {
                goto Label_0447;
            }
            GUIUtility.hotControl = num5;
            if (!Event.current.control)
            {
                if (!base.IsSelected)
                {
                    Selection.activeInstanceID = base.Behaviour.GetInstanceID();
                }
                break;
            }
            if (!base.IsSelected)
            {
                GameObject[] objArray3 = Selection.gameObjects;
                ArrayUtility.Add <GameObject>(ref objArray3, base.Wrapper.Behaviour.gameObject);
                Selection.objects        = objArray3;
                base.hasSelectionChanged = true;
                break;
            }
            GameObject[] objArray2 = Selection.gameObjects;
            ArrayUtility.Remove <GameObject>(ref objArray2, base.Wrapper.Behaviour.gameObject);
            Selection.objects        = (objArray2);
            base.hasSelectionChanged = true;
            break;
        }

        case EventType.MouseUp:
            if (GUIUtility.hotControl == num5)
            {
                mouseDownOffset       = -1f;
                GUIUtility.hotControl = (0);
                if (base.mouseDragActivity)
                {
                    base.TriggerTrackItemUpdateEvent();
                }
                else if (!Event.current.control)
                {
                    Selection.activeInstanceID = (base.Behaviour.GetInstanceID());
                }
                else if (!base.hasSelectionChanged)
                {
                    if (!base.IsSelected)
                    {
                        GameObject[] objArray5 = Selection.gameObjects;
                        ArrayUtility.Add <GameObject>(ref objArray5, base.Wrapper.Behaviour.gameObject);
                        Selection.objects = (objArray5);
                    }
                    else
                    {
                        GameObject[] objArray4 = Selection.gameObjects;
                        ArrayUtility.Remove <GameObject>(ref objArray4, base.Wrapper.Behaviour.gameObject);
                        Selection.objects = (objArray4);
                    }
                }
                base.hasSelectionChanged = false;
            }
            goto Label_0447;

        case (EventType)3:
            if (GUIUtility.hotControl == num5)
            {
                Undo.RecordObject(base.Behaviour, string.Format("Changed {0}", base.Behaviour.name));
                float firetime = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                firetime = state.SnappedTime(firetime - mouseDownOffset);
                if (!base.mouseDragActivity)
                {
                    base.mouseDragActivity = base.Wrapper.Firetime != firetime;
                }
                base.TriggerRequestTrackItemTranslate(firetime);
            }
            goto Label_0447;

        default:
            goto Label_0447;
        }
        base.mouseDragActivity = false;
        mouseDownOffset        = ((Event.current.mousePosition.x - state.Translation.x) / state.Scale.x) - wrapper.Firetime;
        if (!base.TrackControl.TargetTrack.IsLocked)
        {
            Event.current.Use();
        }
Label_0447:
        switch (Event.current.GetTypeForControl(num4))
        {
        case 0:
            if (rect.Contains(Event.current.mousePosition))
            {
                GUIUtility.hotControl = (num4);
                mouseDownOffset       = ((Event.current.mousePosition.x - state.Translation.x) / state.Scale.x) - wrapper.Firetime;
                if (!base.TrackControl.TargetTrack.IsLocked)
                {
                    Event.current.Use();
                }
            }
            break;

        case (EventType)1:
            if (GUIUtility.hotControl == num4)
            {
                mouseDownOffset       = -1f;
                GUIUtility.hotControl = (0);
            }
            break;

        case (EventType)3:
            if (GUIUtility.hotControl == num4)
            {
                float time = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                time = state.SnappedTime(time);
                if (time >= 0f)
                {
                    float num9 = wrapper.InTime - (wrapper.Firetime - time);
                    num9 = Mathf.Clamp(num9, 0f, wrapper.ItemLength);
                    float num10 = num9 - wrapper.InTime;
                    wrapper.InTime    = num9;
                    wrapper.Firetime += num10;
                    if (this.AlterFixedAction != null)
                    {
                        this.AlterFixedAction(this, new ActionFixedItemEventArgs(wrapper.Behaviour, wrapper.Firetime, wrapper.Duration, wrapper.InTime, wrapper.OutTime));
                    }
                }
            }
            break;
        }
        switch (Event.current.GetTypeForControl(num6))
        {
        case 0:
            if (rect3.Contains(Event.current.mousePosition))
            {
                GUIUtility.hotControl = (num6);
                mouseDownOffset       = ((Event.current.mousePosition.x - state.Translation.x) / state.Scale.x) - wrapper.Firetime;
                if (!base.TrackControl.TargetTrack.IsLocked)
                {
                    Event.current.Use();
                }
            }
            break;

        case (EventType)1:
            if (GUIUtility.hotControl == num6)
            {
                mouseDownOffset       = -1f;
                GUIUtility.hotControl = (0);
            }
            break;

        case (EventType)3:
            if (GUIUtility.hotControl == num6)
            {
                float num11 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                float num12 = state.SnappedTime(num11) - (wrapper.Firetime - wrapper.InTime);
                Undo.RecordObject(wrapper.Behaviour, string.Format("Changed {0}", wrapper.Behaviour.name));
                wrapper.OutTime = Mathf.Clamp(num12, 0f, wrapper.ItemLength);
                if (this.AlterFixedAction != null)
                {
                    this.AlterFixedAction(this, new ActionFixedItemEventArgs(wrapper.Behaviour, wrapper.Firetime, wrapper.Duration, wrapper.InTime, wrapper.OutTime));
                }
            }
            break;
        }
        if (Selection.activeGameObject == base.Wrapper.Behaviour.gameObject)
        {
            if ((Event.current.type == (EventType)13) && (Event.current.commandName == "Copy"))
            {
                Event.current.Use();
            }
            if ((Event.current.type == (EventType)14) && (Event.current.commandName == "Copy"))
            {
                DirectorCopyPaste.Copy(base.Wrapper.Behaviour);
                Event.current.Use();
            }
        }
        if (((Event.current.type == (EventType)4) && (Event.current.keyCode == (KeyCode)0x7f)) && (Selection.activeGameObject == base.Wrapper.Behaviour.gameObject))
        {
            base.deleteItem(base.Wrapper.Behaviour);
            Event.current.Use();
        }
    }
예제 #3
0
    public override void HandleInput(DirectorControlState state, Rect trackPosition)
    {
        CinemaActionFixedWrapper cinemaActionFixedWrapper = base.Wrapper as CinemaActionFixedWrapper;

        if (cinemaActionFixedWrapper == null)
        {
            return;
        }
        if (this.isRenaming)
        {
            return;
        }
        float num  = state.TimeToPosition(cinemaActionFixedWrapper.Firetime);
        float num2 = state.TimeToPosition(cinemaActionFixedWrapper.Firetime + cinemaActionFixedWrapper.Duration);

        this.controlPosition = new Rect(num, 0f, num2 - num, trackPosition.height);
        bool  expr_67 = this.controlPosition.width < 15f;
        float num3    = expr_67 ? 0f : 5f;
        Rect  rect    = new Rect(num, 0f, num3, trackPosition.height);
        Rect  rect2   = new Rect(num + num3, 0f, num2 - num - 2f * num3, trackPosition.height);
        Rect  rect3   = new Rect(num2 - num3, 0f, num3, trackPosition.height);

        EditorGUIUtility.AddCursorRect(rect2, (MouseCursor)5);
        if (!expr_67)
        {
            EditorGUIUtility.AddCursorRect(rect, (MouseCursor)3);
            EditorGUIUtility.AddCursorRect(rect3, (MouseCursor)3);
        }
        this.controlID = GUIUtility.GetControlID(cinemaActionFixedWrapper.Behaviour.GetInstanceID(), (FocusType)2, this.controlPosition);
        int controlID  = GUIUtility.GetControlID(cinemaActionFixedWrapper.Behaviour.GetInstanceID(), (FocusType)2, rect);
        int controlID2 = GUIUtility.GetControlID(cinemaActionFixedWrapper.Behaviour.GetInstanceID(), (FocusType)2, rect2);
        int controlID3 = GUIUtility.GetControlID(cinemaActionFixedWrapper.Behaviour.GetInstanceID(), (FocusType)2, rect3);

        if (Event.current.GetTypeForControl(this.controlID) == EventType.MouseDown && rect2.Contains(Event.current.mousePosition) && (int)Event.current.button == 1)
        {
            if (!base.IsSelected)
            {
                GameObject[] gameObjects = Selection.gameObjects;
                ArrayUtility.Add <GameObject>(ref gameObjects, base.Wrapper.Behaviour.gameObject);
                Selection.objects        = (gameObjects);
                this.hasSelectionChanged = true;
            }
            this.showContextMenu(cinemaActionFixedWrapper.Behaviour);
            Event.current.Use();
        }
        switch ((int)Event.current.GetTypeForControl(controlID2))
        {
        case 0:
            if (rect2.Contains(Event.current.mousePosition) && (int)Event.current.button == 0)
            {
                GUIUtility.hotControl = (controlID2);
                if (Event.current.control)
                {
                    if (base.IsSelected)
                    {
                        GameObject[] gameObjects2 = Selection.gameObjects;
                        ArrayUtility.Remove <GameObject>(ref gameObjects2, base.Wrapper.Behaviour.gameObject);
                        Selection.objects        = (gameObjects2);
                        this.hasSelectionChanged = true;
                    }
                    else
                    {
                        GameObject[] gameObjects3 = Selection.gameObjects;
                        ArrayUtility.Add <GameObject>(ref gameObjects3, base.Wrapper.Behaviour.gameObject);
                        Selection.objects        = (gameObjects3);
                        this.hasSelectionChanged = true;
                    }
                }
                else if (!base.IsSelected)
                {
                    Selection.activeInstanceID = (base.Behaviour.GetInstanceID());
                }
                this.mouseDragActivity = false;
                ActionFixedItemControl.mouseDownOffset = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x - cinemaActionFixedWrapper.Firetime;
                Event.current.Use();
            }
            break;

        case 1:
            if (GUIUtility.hotControl == controlID2)
            {
                ActionFixedItemControl.mouseDownOffset = -1f;
                GUIUtility.hotControl = (0);
                if (!this.mouseDragActivity)
                {
                    if (Event.current.control)
                    {
                        if (!this.hasSelectionChanged)
                        {
                            if (base.IsSelected)
                            {
                                GameObject[] gameObjects4 = Selection.gameObjects;
                                ArrayUtility.Remove <GameObject>(ref gameObjects4, base.Wrapper.Behaviour.gameObject);
                                Selection.objects = (gameObjects4);
                            }
                            else
                            {
                                GameObject[] gameObjects5 = Selection.gameObjects;
                                ArrayUtility.Add <GameObject>(ref gameObjects5, base.Wrapper.Behaviour.gameObject);
                                Selection.objects = (gameObjects5);
                            }
                        }
                    }
                    else
                    {
                        Selection.activeInstanceID = (base.Behaviour.GetInstanceID());
                    }
                }
                else
                {
                    base.TriggerTrackItemUpdateEvent();
                }
                this.hasSelectionChanged = false;
            }
            break;

        case 3:
            if (GUIUtility.hotControl == controlID2)
            {
                Undo.RecordObject(base.Behaviour, string.Format("Changed {0}", base.Behaviour.name));
                float num4 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                num4 = state.SnappedTime(num4 - ActionFixedItemControl.mouseDownOffset);
                if (!this.mouseDragActivity)
                {
                    this.mouseDragActivity = (base.Wrapper.Firetime != num4);
                }
                base.TriggerRequestTrackItemTranslate(num4);
            }
            break;
        }
        switch ((int)Event.current.GetTypeForControl(controlID))
        {
        case 0:
            if (rect.Contains(Event.current.mousePosition))
            {
                GUIUtility.hotControl = (controlID);
                ActionFixedItemControl.mouseDownOffset = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x - cinemaActionFixedWrapper.Firetime;
                Event.current.Use();
            }
            break;

        case 1:
            if (GUIUtility.hotControl == controlID)
            {
                ActionFixedItemControl.mouseDownOffset = -1f;
                GUIUtility.hotControl = (0);
            }
            break;

        case 3:
            if (GUIUtility.hotControl == controlID)
            {
                float num5 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                num5 = state.SnappedTime(num5);
                if (num5 >= 0f)
                {
                    float num6 = cinemaActionFixedWrapper.InTime - (cinemaActionFixedWrapper.Firetime - num5);
                    num6 = Mathf.Clamp(num6, 0f, cinemaActionFixedWrapper.ItemLength);
                    float num7 = num6 - cinemaActionFixedWrapper.InTime;
                    cinemaActionFixedWrapper.InTime    = num6;
                    cinemaActionFixedWrapper.Firetime += num7;
                    if (this.AlterFixedAction != null)
                    {
                        this.AlterFixedAction(this, new ActionFixedItemEventArgs(cinemaActionFixedWrapper.Behaviour, cinemaActionFixedWrapper.Firetime, cinemaActionFixedWrapper.Duration, cinemaActionFixedWrapper.InTime, cinemaActionFixedWrapper.OutTime));
                    }
                }
            }
            break;
        }
        switch ((int)Event.current.GetTypeForControl(controlID3))
        {
        case 0:
            if (rect3.Contains(Event.current.mousePosition))
            {
                GUIUtility.hotControl = (controlID3);
                ActionFixedItemControl.mouseDownOffset = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x - cinemaActionFixedWrapper.Firetime;
                Event.current.Use();
            }
            break;

        case 1:
            if (GUIUtility.hotControl == controlID3)
            {
                ActionFixedItemControl.mouseDownOffset = -1f;
                GUIUtility.hotControl = (0);
            }
            break;

        case 3:
            if (GUIUtility.hotControl == controlID3)
            {
                float num8 = (Event.current.mousePosition.x - state.Translation.x) / state.Scale.x;
                num8 = state.SnappedTime(num8);
                float num9 = num8 - (cinemaActionFixedWrapper.Firetime - cinemaActionFixedWrapper.InTime);
                Undo.RecordObject(cinemaActionFixedWrapper.Behaviour, string.Format("Changed {0}", cinemaActionFixedWrapper.Behaviour.name));
                cinemaActionFixedWrapper.OutTime = Mathf.Clamp(num9, 0f, cinemaActionFixedWrapper.ItemLength);
                if (this.AlterFixedAction != null)
                {
                    this.AlterFixedAction(this, new ActionFixedItemEventArgs(cinemaActionFixedWrapper.Behaviour, cinemaActionFixedWrapper.Firetime, cinemaActionFixedWrapper.Duration, cinemaActionFixedWrapper.InTime, cinemaActionFixedWrapper.OutTime));
                }
            }
            break;
        }
        if (Selection.activeGameObject == Wrapper.Behaviour.gameObject)
        {
            if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "Copy")
            {
                Event.current.Use();
            }
            if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "Copy")
            {
                DirectorCopyPaste.Copy(Wrapper.Behaviour);
                Event.current.Use();
            }
        }
        if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Delete && Selection.activeGameObject == Wrapper.Behaviour.gameObject)
        {
            deleteItem(Wrapper.Behaviour);
            Event.current.Use();
        }
    }