public static RadialMenuControl AxisFromParams(RadialMenu menu, string name, Vrc3Param xParam, Vrc3Param yParam)
            {
                var subLabels = new VRCExpressionsMenu.Control.Label[4];

                return(new RadialMenuControl(menu, name, null, ControlType.TwoAxisPuppet, 1f, null, new[] { xParam, yParam }, null, subLabels));
            }
Esempio n. 2
0
        internal override void SetRadialButton(RadialButton button)
        {
            this.button = button;
            if (!(VRCExpressionsMenu.Control.ControlType.FourAxisPuppet == button.Control.type || VRCExpressionsMenu.Control.ControlType.TwoAxisPuppet == button.Control.type))
            {
                Debug.LogError($"Button [{button.name}] is not a MultiAxisPuppet");
                return;
            }

            if (null != rt)
            {
                if (VRCExpressionsMenu.Control.ControlType.FourAxisPuppet == button.Control.type)
                {
                    float pUp    = AvatarController.current.GetParameterValue(button.Control.subParameters[0].name);
                    float pRight = AvatarController.current.GetParameterValue(button.Control.subParameters[1].name);
                    float pDown  = AvatarController.current.GetParameterValue(button.Control.subParameters[2].name);
                    float pLeft  = AvatarController.current.GetParameterValue(button.Control.subParameters[3].name);
                    Joystick.rectTransform.localPosition =
                        new Vector3(
                            maxRadius * (pRight > 0 ? pRight : -1 * pLeft),
                            maxRadius * (pUp > 0 ? pUp : -1 * pDown));
                }
                else if (VRCExpressionsMenu.Control.ControlType.TwoAxisPuppet == button.Control.type)
                {
                    Joystick.rectTransform.localPosition =
                        new Vector3(
                            maxRadius * AvatarController.current.GetParameterValue(button.Control.subParameters[0].name),
                            maxRadius * AvatarController.current.GetParameterValue(button.Control.subParameters[1].name));
                }
            }

            VRCExpressionsMenu.Control.Label up = button.Control.GetLabel(0);
            if (null != up.icon)
            {
                UpSprite = Sprite.Create(up.icon, new Rect(0.0f, 0.0f, up.icon.width, up.icon.height), new Vector2(0.5f, 0.5f));
                RadialButton.SetImageSprite(Up, UpSprite);
            }
            if (!string.IsNullOrEmpty(up.name))
            {
                Up.transform.Find("Text").GetComponent <Text>().text = up.name;
            }

            VRCExpressionsMenu.Control.Label down = button.Control.GetLabel(2);
            if (null != down.icon)
            {
                DownSprite = Sprite.Create(down.icon, new Rect(0.0f, 0.0f, down.icon.width, down.icon.height), new Vector2(0.5f, 0.5f));
                RadialButton.SetImageSprite(Down, DownSprite);
            }
            if (!string.IsNullOrEmpty(down.name))
            {
                Down.transform.Find("Text").GetComponent <Text>().text = down.name;
            }

            VRCExpressionsMenu.Control.Label left = button.Control.GetLabel(3);
            if (null != left.icon)
            {
                LeftSprite = Sprite.Create(left.icon, new Rect(0.0f, 0.0f, left.icon.width, left.icon.height), new Vector2(0.5f, 0.5f));
                RadialButton.SetImageSprite(Left, LeftSprite);
            }
            if (!string.IsNullOrEmpty(left.name))
            {
                Left.transform.Find("Text").GetComponent <Text>().text = left.name;
            }

            VRCExpressionsMenu.Control.Label right = button.Control.GetLabel(1);
            if (null != right.icon)
            {
                RightSprite = Sprite.Create(right.icon, new Rect(0.0f, 0.0f, right.icon.width, right.icon.height), new Vector2(0.5f, 0.5f));
                RadialButton.SetImageSprite(Right, RightSprite);
            }
            if (!string.IsNullOrEmpty(right.name))
            {
                Right.transform.Find("Text").GetComponent <Text>().text = right.name;
            }
        }