Exemplo n.º 1
0
    static void TouchBar_Manager_OnReady()
    {
        TouchBar.Manager.OnReady -= TouchBar_Manager_OnReady;
        editorGroup = new TouchBar.Group("editor", 1, () => {
            dbutton.Highlight(SceneView.GetFlag("in2DMode"));
        });
        cameras = editorGroup.AddSegments("cameramodes", 6);
        dbutton = editorGroup.AddTextButton("2d", "2D", () => {
            bool valu = !SceneView.GetFlag("in2DMode");
            SceneView.SetFlag("in2DMode", valu);
            dbutton.Highlight(valu);
        });

        addbutton = editorGroup.AddImageButton("addgameobject", "/Editor/UniTouchBar/Icons/go.png", "", () => {
            GameObject gm = new GameObject("GameObject");
            Selection.activeGameObject = gm;
        });

        TouchBar.AddGroup(editorGroup);

        editorGroup.ShowOnWindow(TouchBar.Windows.Scene);
        editorGroup.ShowOnWindow(TouchBar.Windows.Hierarchy);

        cameras.SetOptionWithImage(0, "/Editor/UniTouchBar/Icons/hand.png", () => {
            TouchBar.Log("Option");

            Tools.current = Tool.View;
        },
                                   35);
        cameras.SetOptionWithImage(1, "/Editor/UniTouchBar/Icons/move.png", () => {
            Tools.current = Tool.Move;
        },
                                   35);
        cameras.SetOptionWithImage(2, "/Editor/UniTouchBar/Icons/rotate.png", () => {
            Tools.current = Tool.Rotate;
        },
                                   35);
        cameras.SetOptionWithImage(3, "/Editor/UniTouchBar/Icons/resize.png", () => {
            Tools.current = Tool.Scale;
        },
                                   35);

        cameras.SetOptionWithImage(4, "/Editor/UniTouchBar/Icons/transform.png", () => {
            Tools.current = Tool.Transform;
        },
                                   35);

        cameras.SetOptionWithImage(5, "/Editor/UniTouchBar/Icons/rect.png", () => {
            Tools.current = Tool.Rect;
        },
                                   35);
    }
Exemplo 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"))
            {
            }
        };
    }