Ejemplo n.º 1
0
 static void SegmentClick()
 {
     if (AnimatorEditor.GetFlag("playing"))
     {
         segments.Select(2);
     }
     else
     {
         segments.Select(-1);
     }
 }
Ejemplo n.º 2
0
    static void TouchBar_Manager_OnReady()
    {
        TouchBar.Manager.OnReady -= TouchBar_Manager_OnReady;
        EditorApplication.update += EditorApplication_Update;
        group = new TouchBar.Group("animation", 4);

        segments = group.AddSegments("segments", 5);

        recordButton = group.AddImageButton("record", "/Editor/UniTouchBar/Icons/record.png", "", () => {
            if (AnimatorEditor.GetFlag("recording"))
            {
                //STOP
                System.Type.GetType("UnityEditorInternal.AnimationWindowState, UnityEditor.dll").GetMethod("StopRecording").Invoke(AnimatorEditor.stateWindow, null);
                recordButton.UpdateImage("/Editor/UniTouchBar/Icons/record.png");
            }
            else
            {
                //START
                System.Type.GetType("UnityEditorInternal.AnimationWindowState, UnityEditor.dll").GetMethod("StartRecording").Invoke(AnimatorEditor.stateWindow, null);
                recordButton.UpdateImage("/Editor/UniTouchBar/Icons/recording.png");
            }
            AnimatorEditor.Repaint();
        });

        slider = group.AddSlider("slider", 0, 100, 1, (double obj) => {
            try {
                object[] parameters = new object[] {
                    (float)obj
                };
                System.Type.GetType("UnityEditorInternal.IAnimationWindowControl, UnityEditor.dll").GetMethod("GoToTime").Invoke(AnimatorEditor.controlInterface, parameters);
                AnimatorEditor.Repaint();
            } catch (System.Exception ex) {
                TouchBar.Log(ex);
            }

            ///TouchBar.Log(System.Type.GetType("UnityEditorInternal.AnimationWindowState, UnityEditor.dll").GetProperty("maxTime").GetValue(AnimatorEditor.stateWindow, null));
        });
        TouchBar.AddGroup(group);
        segments.SetOptionWithImage(0, "/Editor/UniTouchBar/Icons/segment_rewind_back.png", () => {
            System.Type.GetType("UnityEditorInternal.IAnimationWindowControl, UnityEditor.dll").GetMethod("GoToFirstKeyframe").Invoke(AnimatorEditor.controlInterface, null);
            AnimatorEditor.Repaint();
            AnimatorTouchBar.SegmentClick();
        });
        segments.SetOptionWithImage(1, "/Editor/UniTouchBar/Icons/segment_step_back.png", () => {
            System.Type.GetType("UnityEditorInternal.IAnimationWindowControl, UnityEditor.dll").GetMethod("GoToPreviousKeyframe").Invoke(AnimatorEditor.controlInterface, null);
            AnimatorEditor.Repaint();
            AnimatorTouchBar.SegmentClick();
        });
        segments.SetOptionWithImage(2, "/Editor/UniTouchBar/Icons/segment_play.png", () => {
            if (AnimatorEditor.GetFlag("playing"))
            {
                //STOP
                segments.Select(-1);
                System.Type.GetType("UnityEditorInternal.AnimationWindowState, UnityEditor.dll").GetMethod("StopPlayback").Invoke(AnimatorEditor.stateWindow, null);
            }
            else
            {
                //START
                segments.Select(2);
                System.Type.GetType("UnityEditorInternal.AnimationWindowState, UnityEditor.dll").GetMethod("StartPlayback").Invoke(AnimatorEditor.stateWindow, null);
            }
            AnimatorEditor.Repaint();
        });
        segments.SetOptionWithImage(3, "/Editor/UniTouchBar/Icons/segment_step.png", () => {
            System.Type.GetType("UnityEditorInternal.IAnimationWindowControl, UnityEditor.dll").GetMethod("GoToNextKeyframe").Invoke(AnimatorEditor.controlInterface, null);
            AnimatorEditor.Repaint();
            AnimatorTouchBar.SegmentClick();
        });
        segments.SetOptionWithImage(4, "/Editor/UniTouchBar/Icons/segment_rewind.png", () => {
            System.Type.GetType("UnityEditorInternal.IAnimationWindowControl, UnityEditor.dll").GetMethod("GoToLastKeyframe").Invoke(AnimatorEditor.controlInterface, null);
            AnimatorEditor.Repaint();
            AnimatorTouchBar.SegmentClick();
        });

        group.ShowOnWindow(TouchBar.Windows.Animation);
        group.ShowOnWindow(TouchBar.Windows.Scene);
        group.OnShow += () => {
            AnimatorEditor.Clean();
            //            TouchBar.Log("Hello");
            loaded = true;
            if (AnimatorEditor.window == null)
            {
                group.Hide();
                loaded = false;
            }

            if ((EditorWindow.focusedWindow != null) && (EditorWindow.focusedWindow.titleContent.text == "Scene"))
            {
            }
        };
    }