Exemplo n.º 1
0
        public void initButton(int btnXLocation, int btnYLocation, String btnText, String btnToolTip, Color btnBackgroundColor, Color btnTextColor, Color backbtnBackgroundColor, Color backbtnTextColor)
        {
            Transform menu = UnityEngine.Object.Instantiate <Transform>(QuickMenuStuff.GetQuickMenuInstance().transform.Find("CameraMenu"), QuickMenuStuff.GetQuickMenuInstance().transform);

            menuName  = "CustomMenu" + btnQMLoc + "_" + btnXLocation + "_" + btnYLocation;
            menu.name = menuName;

            mainButton = new QMSingleButton(btnQMLoc, btnXLocation, btnYLocation, btnText, delegate() { QuickMenuStuff.ShowQuickmenuPage(menuName); }, btnToolTip, btnBackgroundColor, btnTextColor);

            IEnumerator enumerator = menu.transform.GetEnumerator();

            while (enumerator.MoveNext())
            {
                object    obj     = enumerator.Current;
                Transform btnEnum = (Transform)obj;
                if (btnEnum != null)
                {
                    UnityEngine.Object.Destroy(btnEnum.gameObject);
                }
            }

            if (backbtnTextColor == null)
            {
                backbtnTextColor = Color.yellow;
            }
            backButton = new QMSingleButton(this, 4, 2, "Back", delegate() { QuickMenuStuff.ShowQuickmenuPage(btnQMLoc); }, "Go Back", backbtnBackgroundColor, backbtnTextColor);
        }
Exemplo n.º 2
0
        //BtnMenu -> this has 3 possible types, "ShortcutMenu", "UserInteractMenu" or a QMNestedButton (button that opens up to other buttons)
        //ShortcutMenu -> main quick menu with worlds/avatars

        public static IEnumerator CreateButton(MenuType Menu, ButtonType type, string ButtonText, int X, int Y, UnityAction action, string buttonTooltip, Color color, Color BtnText, QMNestedButton MainButton = null, string SpriteImage = null, string OnText = null, string OffText = null, UnityAction OffAction = null, Color?BackButtonColor = null, Color?BackButtonTextColor = null)
        {
            string MenuString = "ShortcutMenu";

            switch (Menu)
            {
            default: MenuString = "ShortcutMenu"; break;

            case MenuType.ShortCut: MenuString = "ShortcutMenu"; break;

            case MenuType.UserInteract: MenuString = "UserInteractMenu"; break;

            case MenuType.UserInfo: MenuString = "UserInfo"; break;
            }

            switch (type)
            {
            default: break;

            case ButtonType.Single:
                QMSingleButton x = null;
                if (MainButton != null)
                {
                    x = new QMSingleButton(MainButton, X, Y, ButtonText, action, buttonTooltip, color, BtnText);
                }
                else
                {
                    x = new QMSingleButton(MenuString, X, Y, ButtonText, action, buttonTooltip, color, BtnText);
                }

                if (SpriteImage != null)
                {
                    var sprite = new Sprite();

                    using (WWW www = new WWW(SpriteImage))
                    {
                        yield return(www);

                        sprite = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height),
                                               new Vector2(0, 0));
                    }

                    x.getGameObject().GetComponentInChildren <UnityEngine.UI.Image>().sprite = sprite;
                    Material logoMaterial = new Material(x.getGameObject().GetComponentInChildren <UnityEngine.UI.Image>().material);
                    logoMaterial.shader = Shader.Find("Unlit/Transparent");
                    x.getGameObject().GetComponentInChildren <UnityEngine.UI.Image>().material = logoMaterial;
                }
                UIHelper.ButtonOutput.Add(x);
                break;

            case ButtonType.Toggle:
                QMToggleButton y = null;
                if (MainButton != null)
                {
                    y = new QMToggleButton(MainButton, X, Y, OnText, action, OffText, OffAction, buttonTooltip, color, BtnText);
                }
                else
                {
                    y = new QMToggleButton(MenuString, X, Y, OnText, action, OffText, OffAction, buttonTooltip, color, BtnText);
                }


                if (SpriteImage != null)
                {
                    var sprite = new Sprite();

                    using (WWW www = new WWW(SpriteImage))
                    {
                        sprite = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height),
                                               new Vector2(0, 0));
                    }

                    y.getGameObject().GetComponentInChildren <UnityEngine.UI.Image>().sprite = sprite;
                    Material logoMaterial = new Material(y.getGameObject().GetComponentInChildren <UnityEngine.UI.Image>().material);
                    logoMaterial.shader = Shader.Find("Unlit/Transparent");
                    y.getGameObject().GetComponentInChildren <UnityEngine.UI.Image>().material = logoMaterial;
                }
                UIHelper.ButtonOutput.Add(y);
                break;

            case ButtonType.Nested:
                if (MainButton != null)
                {
                    var f = new QMNestedButton(MainButton, X, Y, ButtonText, buttonTooltip, color, BtnText, (Color)BackButtonColor, (Color)BackButtonTextColor);
                    UIHelper.ButtonOutput.Add(f);
                }
                else
                {
                    var z = new QMNestedButton(MenuString, X, Y, ButtonText, buttonTooltip, color, BtnText, (Color)BackButtonColor, (Color)BackButtonTextColor);
                    UIHelper.ButtonOutput.Add(z);
                }
                break;
            }
        }