Example #1
0
    static void TouchBar_Manager_OnReady()
    {
        TouchBar.Manager.OnReady -= TouchBar_Manager_OnReady;
        gameGroup = new TouchBar.Group("game", 3);

        pauseButton = gameGroup.AddImageButton("pause", "/Editor/UniTouchBar/Icons/pause.png", "", () => {
            EditorApplication.isPaused = !EditorApplication.isPaused;

            CheckPause();
        });

        TouchBar.Button space = gameGroup.AddTextButton("space", "     ");

        muteButton = gameGroup.AddTextButton("mute", "mute", () => {
            EditorUtility.audioMasterMute = !EditorUtility.audioMasterMute;
            muteButton.Highlight(EditorUtility.audioMasterMute);
        });

        statsButton = gameGroup.AddTextButton("stats", "stats", () => {
            bool val = !EditGameView.GetFlag("m_Stats");
            EditGameView.SetFlag("m_Stats", val);
            statsButton.Highlight(val);
        });

        maximizeButton = gameGroup.AddImageButton("maximize", "/Editor/UniTouchBar/Icons/resize.png", "", () => {
            bool val = !EditGameView.GetMaximized();
            EditGameView.Maximize(val);
            maximizeButton.Highlight(val);
        });

        TouchBar.AddGroup(gameGroup);
        space.Hide();
    }
Example #2
0
    static void DynamicGroup()
    {
        //No need to init it double times
        if (moreGroup == null)
        {
            moreGroup = new TouchBar.Group("slidersGroup", 6);

            slider = moreGroup.AddSlider("slider", 0, 10, 3, (double value) => {
                Debug.Log("On Slider change [value:" + value.ToString() + "]");
            });

            //Close group button
            moreGroup.AddImageButton("close", "/Editor/UniTouchBar/Icons/close.png", "", () => {
                if (moreGroup != null) //Shit happens - shouldn't but in case of!.
                {
                    moreGroup.Hide();
                }
            });

            //Let's add and show!
            TouchBar.AddGroup(moreGroup);
            //We can hide buttons
            moreGroup.OnHidden += () => {
                showSliderButton.Show();
            };
            moreGroup.OnShow += () => {
                showSliderButton.Hide();
            };
        }

        moreGroup.Show();
    }
Example #3
0
    static void TouchBar_Manager_OnReady()
    {
        TouchBar.Manager.OnReady -= TouchBar_Manager_OnReady;
        mainGroup  = new TouchBar.Group("main", 0);
        playButton = mainGroup.AddImageButton("play", "/Editor/UniTouchBar/Icons/play.png", "", () => {
            playButton.UpdateBackgroundColor(new Color(0.5F, 0.5F, 0.5F));
            EditorApplication.isPlaying = !EditorApplication.isPlaying;
        });

        mainGroup.ShowOnWindow(TouchBar.Windows.ALL);
        TouchBar.AddGroup(mainGroup);
    }
Example #4
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);
    }
Example #5
0
 static void TouchBar_Manager_OnReady()
 {
     TouchBar.Manager.OnReady -= TouchBar_Manager_OnReady;
     EditorApplication.update += EditorApplication_Update;
     gameobjectGroup           = new TouchBar.Group("gameobject", 4);
     enableButton              = gameobjectGroup.AddImageButton("enabled", "/Editor/UniTouchBar/Icons/enabled.png", "", () => {
         if (Selection.activeGameObject != null)
         {
             Selection.activeGameObject.SetActive(!Selection.activeGameObject.activeSelf);
         }
     });
     gameobjectGroup.ShowOnWindow(TouchBar.Windows.None);
     ready = true;
     TouchBar.AddGroup(gameobjectGroup);
 }
Example #6
0
    static void TouchBar_Manager_OnReady()
    {
        TouchBar.Manager.OnReady -= TouchBar_Manager_OnReady;
        projectGroup              = new TouchBar.Group("project", 2);

        foreach (var item in AssetDatabase.FindAssets("t:scene"))
        {
            string     path  = AssetDatabase.GUIDToAssetPath(item);
            SceneAsset scene = AssetDatabase.LoadAssetAtPath <SceneAsset> (path) as SceneAsset;
            if (scene != null)
            {
                projectGroup.AddImageButton("scene" + scene.name, "/Editor/UniTouchBar/Icons/unity.png", scene.name, () => {
                    EditorSceneManager.OpenScene(path, OpenSceneMode.Single);
                });
            }
        }

        projectGroup.AddImageButton("finder", "/Editor/UniTouchBar/Icons/finder.png", "", () => {
            OpenInMac(AssetDatabase.GetAssetPath(Selection.activeObject));
        });

        TouchBar.AddGroup(projectGroup);
        projectGroup.ShowOnWindow(TouchBar.Windows.Project);
    }
Example #7
0
    //private static TouchBar.Button closeButton;
    static void DynamicGroup()
    {
        //No need to init it double times
        if (moreGroup == null)
        {
            moreGroup = new TouchBar.Group("moreGroup", 6);

            coolButton = moreGroup.AddTextButton("cool", "made by IMVOLUTE \ud83d\ude0e");

            //You can allways add action to already created items.
            coolButton.onClick = () => {
                Application.OpenURL("https://imvolute.com");
            };

            //Making image button - is also easy ;)
            moreGroup.AddImageButton("close", "/Editor/UniTouchBar/Icons/close.png", "", () => {
                if (moreGroup != null) //Shit happens - shouldn't but in case of!.
                {
                    moreGroup.Hide();
                }
            });

            //Let's add and show!
            TouchBar.AddGroup(moreGroup);
            moreGroup.Show();

            //Wow wow - what if we hide settings? This group has to hide too!
            settingsGroup.OnHidden += () => {
                if (moreGroup != null)
                {
                    moreGroup.Hide();
                }
            };
        }
        else
        {
            //No need to recreate - just show!
            moreGroup.Show();
        }

        //Cool idea! What if we chnage more... to more?
    }
Example #8
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"))
            {
            }
        };
    }