public RadialButton CreateButton(VRCExpressionsMenu.Control control, float xpos, float ypos) { RadialButton newButton = Instantiate(RadialMenuController.current.ButtonPrefab) as RadialButton; Button selectable = newButton.GetComponent <Button>(); if (null == control) { if (null == Parent) { selectable.interactable = false; control = new VRCExpressionsMenu.Control() { icon = RadialMenuController.current.HomeIcon, name = "home" }; } else { selectable.onClick.AddListener(delegate { RadialMenuController.current.SwapMenu(this, Parent); }); control = new VRCExpressionsMenu.Control() { icon = RadialMenuController.current.BackIcon, name = "back" }; } } newButton.Initialize(this, control, xpos, ypos); newButton.gameObject.name = control.name; return(newButton); }
/** * Close the Control Menu and activate the menu */ internal void CloseControl(RadialButton button, Control control) { control.gameObject.SetActive(false); if (null != MenuActivationEvent) { MenuActivationEvent(ControlType.All, true); } OnRadialButtonEvent(button); }
internal override void SetRadialButton(RadialButton button) { this.button = button; if (VRCExpressionsMenu.Control.ControlType.RadialPuppet == button.Control.type) { Slider slider = GetComponent <Slider>(); slider.value = AvatarController.current.GetParameterValue(button.Control.subParameters[0].name); slider.onValueChanged.RemoveAllListeners(); slider.onValueChanged.AddListener(delegate(float value) { AvatarController.current.ExpressionParameterSet(button.Control, value); }); } }
internal void OnRadialButtonEvent(RadialButton radialButton) { //toggle the root parameter radialButton.SetActive(!radialButton.isOn); if (VRCExpressionsMenu.Control.ControlType.Button == radialButton.Control.type) { if (radialButton.isOn) { radialButton.Selectable.interactable = false; pressedButtons.Add(new ButtonWait { button = radialButton, duration = 0 }); } else { radialButton.Selectable.interactable = true; } } if (radialButton.isOn && VRCExpressionsMenu.Control.ControlType.RadialPuppet == radialButton.Control.type) { RadialPuppet.SetRadialButton(radialButton); RadialPuppet.gameObject.SetActive(true); if (null != MenuActivationEvent) { MenuActivationEvent(ControlType.All, false); } } if (radialButton.isOn && VRCExpressionsMenu.Control.ControlType.FourAxisPuppet == radialButton.Control.type) { MultiAxisPuppet.SetRadialButton(radialButton); MultiAxisPuppet.gameObject.SetActive(true); if (null != MenuActivationEvent) { MenuActivationEvent(ControlType.All, false); } } if (radialButton.isOn && VRCExpressionsMenu.Control.ControlType.TwoAxisPuppet == radialButton.Control.type) { MultiAxisPuppet.SetRadialButton(radialButton); MultiAxisPuppet.gameObject.SetActive(true); if (null != MenuActivationEvent) { MenuActivationEvent(ControlType.All, false); } } }
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); } }
abstract internal void SetRadialButton(RadialButton button);
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; } }