示例#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);
    }
示例#2
0
    static void Manager_OnReady()
    {
        //Ready? We don't need it anymore. - keep it fast!
        TouchBar.Manager.OnReady -= Manager_OnReady;

        //--------------------1.GROUP----------------------------
        //--Everything is allways stored in groups.
        settingsGroup = new TouchBar.Group("settingsGroup", 5, () => {
            TouchBar.Log("Settings Touchbar Loaded - Welcome in debug ;)");
        });

        //--------------------2.Items-----------------------------
        //Ok now buttons - all Items are created inside the group ok?
        websiteButton = settingsGroup.AddTextButton("websiteButton", "Website", () => {
            //Button cliked. What now?
            Application.OpenURL("http://imvolute.com/unitouchbar/");
        });

        //--FAQ BUTTON
        faqButton = settingsGroup.AddTextButton("faqButton", "FAQ", () => {
            Application.OpenURL("http://imvolute.com/unitouchbar/faq");
        });


        //--Ok we have buttons. Let's show the group only on Settings Window ;)

        //--------------------------3.SHOW-------------------------
        TouchBar.AddGroup(settingsGroup);
        //--Let's show the touchbar only on window called "Uni.Settings" (basing on what EditorWindow..titleContent.text says)
        settingsGroup.ShowOnWindow("Uni.Settings");

        //--Do you want to keep this group shown all time?
        //mainGroup.ShowOnWindow (TouchBar.Windows.ALL);



        //--------------------That's it!----------------------------
        //LET'S ENCHANCE IT!


        //But we still can make our touchbar more complex.
        //Eq.Set Colors
        websiteButton.UpdateBackgroundColor(new Color(0.352941176F, 0, 1));
        faqButton.UpdateBackgroundColor(new Color(0.352941176F, 0, 1));

        //But nothig happens if you just add dynamic buttons (less efficient)
        TouchBar.Button moreButton = settingsGroup.AddTextButton("moreButton", "more...", () => {
            //Maybe we will link some group to the button?
            DynamicGroup();
        });

        //We can log to check if everything works.
        TouchBar.Log(moreButton);

        //But dynamic items need reloading :( //After adding all items.
        TouchBar.ReloadGroup(settingsGroup);
    }
示例#3
0
    static void TouchBar_Manager_OnReady()
    {
        TouchBar.Manager.OnReady -= TouchBar_Manager_OnReady;
        consoleGroup              = new TouchBar.Group("console", 1);

        clearButton = consoleGroup.AddTextButton("clear", "Clear", () => {
            EditConsole.Clear();
        });

        collapse = consoleGroup.AddTextButton("collapse", "Collapse", () => {
            if (EditConsole.GetFlag(EditConsole.ConsoleFlags.Collapse))
            {
                collapse.UpdateBackgroundColor(new Color(0.26F, 0.26F, 0.26F));
                EditConsole.SetFlag(EditConsole.ConsoleFlags.Collapse, false);
            }
            else
            {
                collapse.UpdateBackgroundColor(new Color(0.5F, 0.5F, 0.5F));

                EditConsole.SetFlag(EditConsole.ConsoleFlags.Collapse, true);
            }
        });
        clearOnPlay = consoleGroup.AddTextButton("clearplay", "ClearOnPlay", () => {
            if (EditConsole.GetFlag(EditConsole.ConsoleFlags.ClearOnPlay))
            {
                clearOnPlay.UpdateBackgroundColor(new Color(0.26F, 0.26F, 0.26F));
                EditConsole.SetFlag(EditConsole.ConsoleFlags.ClearOnPlay, false);
            }
            else
            {
                clearOnPlay.UpdateBackgroundColor(new Color(0.5F, 0.5F, 0.5F));

                EditConsole.SetFlag(EditConsole.ConsoleFlags.ClearOnPlay, true);
            }
        });
        errorPause = consoleGroup.AddTextButton("errorpause", "ErrorPause", () => {
            if (EditConsole.GetFlag(EditConsole.ConsoleFlags.ErrorPause))
            {
                errorPause.UpdateBackgroundColor(new Color(0.26F, 0.26F, 0.26F));
                EditConsole.SetFlag(EditConsole.ConsoleFlags.ErrorPause, false);
            }
            else
            {
                errorPause.UpdateBackgroundColor(new Color(0.5F, 0.5F, 0.5F));

                EditConsole.SetFlag(EditConsole.ConsoleFlags.ErrorPause, true);
            }
        });

        TouchBar.AddGroup(consoleGroup);
        consoleGroup.ShowOnWindow(TouchBar.Windows.Console);
        consoleGroup.OnShow += ConsoleGroup_OnShow;
        //cameras.SetOptionWithText(0, "elo", () => { });
    }
示例#4
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);
    }
示例#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);
 }
示例#6
0
    static void Manager_OnReady()
    {
        //Ready? We don't need it anymore. - keep it fast!
        TouchBar.Manager.OnReady -= Manager_OnReady;

        //--------------------1.GROUP----------------------------
        //--Everything is allways stored in groups.
        sliderGroup = new TouchBar.Group("sliderGroup", 2, () => {
            TouchBar.Log("Sliders Touchbar Loaded - you can remove it)");
        });

        //--------------------2.Items-----------------------------
        showSliderButton = sliderGroup.AddTextButton("slidersButton", "show", () => {
            //Show group of sliders.
            DynamicGroup();
        });

        //--------------------------3.SHOW-------------------------
        TouchBar.AddGroup(sliderGroup);
        //--Let's show the touchbar on all windows! for specyfic check Uni.TouchBar.Windows or string (basing on what EditorWindow..titleContent.text says)
        sliderGroup.ShowOnWindow(Uni.TouchBar.Windows.ALL);
        //--------------------That's it!----------------------------
    }
示例#7
0
 static void TouchBar_Manager_OnReady()
 {
     TouchBar.Manager.OnReady -= TouchBar_Manager_OnReady;
     colorGroup = new TouchBar.Group("color", 1, () => {
         Color[] colors = Colors.GetColors();
         if (colors != null)
         {
             foreach (Color item in colors)
             {
                 if (colorGroup.items.Find((obj) => obj.identifier == item.ToString()) == null)
                 {
                     TouchBar.Button button = colorGroup.AddTextButton(item.ToString(), " ", () => {
                         //							  TouchBar.Log(item.ToString());
                         Colors.SetColor(item);
                     });
                     button.Add(colorGroup.identifier);
                     button.UpdateBackgroundColor(item);
                 }
             }
         }
     });
     TouchBar.AddGroup(colorGroup);
     colorGroup.ShowOnWindow(TouchBar.Windows.Color);
 }
示例#8
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);
    }
示例#9
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"))
            {
            }
        };
    }