public RadialMenu CreateMainMenu(VRCExpressionsMenu menu, VRCExpressionParameters parameters)
        {
            RadialMenu rMenu = Instantiate(RadialMenuPrefab) as RadialMenu;

            rMenu.gameObject.name = menu.name;
            rMenu.Initialize(null, menu, parameters);
            rMenu.transform.SetParent(transform, false);
            rMenu.gameObject.SetActive(false);
            return(rMenu);
        }
        public RadialMenu CreateMenu(RadialMenu parent, VRCExpressionsMenu.Control control)
        {
            RadialMenu rMenu = Instantiate(RadialMenuPrefab) as RadialMenu;

            rMenu.gameObject.name = control.subMenu.name;
            rMenu.Initialize(parent, control.subMenu, parameters);
            rMenu.transform.SetParent(transform, false);
            rMenu.gameObject.SetActive(false);

            subMenus.Add(rMenu.gameObject);
            return(rMenu);
        }
Exemplo n.º 3
0
        public void Initialize(RadialMenu parent, VRCExpressionsMenu menu, VRCExpressionParameters parameters)
        {
            this.Parent     = parent;
            this.VRCMenu    = menu;
            this.Parameters = parameters;

            backButton = CreateButton(null, 0, 1);

            //Debug.Log("VRCMenu: null=" + (null == VRCMenu) + " : control="+ (null==VRCMenu.controls));
            int buttonCount = VRCMenu.controls.Count + 1;
            int buttonIndex = 1;

            foreach (VRCExpressionsMenu.Control control in VRCMenu.controls)
            {
                float theta = (2 * Mathf.PI / buttonCount) * buttonIndex++;
                float xpos  = Mathf.Sin(theta);
                float ypos  = Mathf.Cos(theta);
                CreateButton(control, xpos, ypos);
            }
        }
 internal void SwapMenu(RadialMenu showing, RadialMenu parent)
 {
     showing.gameObject.SetActive(false);
     parent.gameObject.SetActive(true);
 }
Exemplo n.º 5
0
        public void Initialize(RadialMenu parent, VRCExpressionsMenu.Control control, float xpos, float ypos)
        {
            this.RadialMenu = parent;
            this.Control    = control;
            this.xpos       = xpos;
            this.ypos       = ypos;
            Texture2D tex = Control.icon ?? null;

            this.Selectable = GetComponent <Button>();

            RadialMenuController.current.MenuActivationEvent += MenuActivationEvent;

            string error = "";

            if (VRCExpressionsMenu.Control.ControlType.SubMenu == Control.type)
            {
                if (null == tex)
                {
                    tex = RadialMenuController.current.SubMenuIcon;
                }

                if (null == Control.subMenu)
                {
                    Error = true;
                    error = $"Sub Menu [{control.name}] is not set";
                    TEA_Manager.SDKError(error);
                }
                else
                {
                    SubMenu = RadialMenuController.current.CreateMenu(parent, Control);
                }
            }
            if (VRCExpressionsMenu.Control.ControlType.RadialPuppet == Control.type)
            {
                if (null == tex)
                {
                    tex = RadialMenuController.current.RadialPuppetIcon;
                }

                if (null == Control.subParameters[0] || string.IsNullOrEmpty(Control.subParameters[0].name))
                {
                    error = $"Radial Puppet [{control.name}] does not have a Rotation Parameter";
                    TEA_Manager.SDKError(error);
                    Error = true;
                }
            }
            if (VRCExpressionsMenu.Control.ControlType.TwoAxisPuppet == Control.type)
            {
                if (null == tex)
                {
                    tex = RadialMenuController.current.TwoAxisIcon;
                }
                if ((null == Control.subParameters[0] || string.IsNullOrEmpty(Control.subParameters[0].name)) && (null == Control.subParameters[1] || string.IsNullOrEmpty(Control.subParameters[1].name)))
                {
                    Error = true;
                    error = $"Two Axis Radial Puppet [{control.name}] does not have a either Horizontal or Vertical Parameters";
                    TEA_Manager.SDKError(error);
                }
            }
            if (VRCExpressionsMenu.Control.ControlType.Toggle == Control.type)
            {
                if (null == tex)
                {
                    tex = RadialMenuController.current.ToggleIcon;
                }
            }
            if (VRCExpressionsMenu.Control.ControlType.FourAxisPuppet == Control.type)
            {
                if (null == tex)
                {
                    tex = RadialMenuController.current.FourAxisIcon;
                }
                if ((null == Control.subParameters[0] || string.IsNullOrEmpty(Control.subParameters[0].name)) &&
                    (null == Control.subParameters[1] || string.IsNullOrEmpty(Control.subParameters[1].name)) &&
                    (null == Control.subParameters[2] || string.IsNullOrEmpty(Control.subParameters[2].name)) &&
                    (null == Control.subParameters[3] || string.IsNullOrEmpty(Control.subParameters[3].name)))
                {
                    Error = true;
                    error = $"Four Axis Radial Puppet [{control.name}] is missing a parameter";
                    TEA_Manager.SDKError(error);
                }
            }
            if (VRCExpressionsMenu.Control.ControlType.Button == Control.type)
            {
                if (null == tex)
                {
                    tex = RadialMenuController.current.ButtonIcon;
                }
            }

            if (!Error)
            {
                transform.Find("Text").GetComponent <Text>().text = Control.name;
                if (null != tex)
                {
                    sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f));
                    SetImageSprite(image, sprite);
                }
            }
            else
            {
                sprite = RadialMenuController.current.ErrorSprite;
                SetImageSprite(image, sprite);
                transform.Find("Text").GetComponent <Text>().text = error;
            }

            transform.SetParent(RadialMenu.transform);
            SetScale();
            SetOnClick();
        }
Exemplo n.º 6
0
 public RadialButton(RadialMenu radialMenu, VRCExpressionsMenu.Control control)
 {
     this.RadialMenu = radialMenu;
     this.Control    = control;
     this.Selectable = GetComponent <Button>();
 }