Esempio n. 1
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();
    }
Esempio n. 2
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?
    }
Esempio n. 3
0
    static void EditorApplication_Update()
    {
        if (ready == true)
        {
            if (Selection.activeGameObject != null)
            {
                gameobjectGroup.Show();

                if ((Selection.activeGameObject.GetComponent <Animator> () != null) || (Selection.activeGameObject.GetComponent <Animation> () != null))
                {
                    //                    TouchBar.Log("ej");
                    if (AnimatorTouchBar.loaded)
                    {
                        if (AnimatorTouchBar.group.windowMask == (AnimatorTouchBar.group.windowMask | (1 << (int)TouchBar.Windows.Scene)))
                        {
                            AnimatorTouchBar.group.Show();
                        }
                    }
                }
                else
                {
                    AnimatorTouchBar.group.Hide();
                }

                if (Selection.activeGameObject.activeSelf)
                {
                    if (!tick)
                    {
                        enableButton.UpdateImage("/Editor/UniTouchBar/Icons/enabled.png");
                        tick = true;
                    }
                }
                else
                {
                    if (tick)
                    {
                        enableButton.UpdateImage("/Editor/UniTouchBar/Icons/disabled.png");
                        tick = false;
                    }
                }
            }
            else
            {
                if (AnimatorTouchBar.loaded)
                {
                    AnimatorTouchBar.group.Hide();
                }

                gameobjectGroup.Hide();
            }
        }
    }
Esempio n. 4
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"))
            {
            }
        };
    }