private bool Initialized() { if (_initialized) { return(true); } VRCAvatarDescriptor avatar = TEA_Manager.current.Avatar; if (null == avatar) { return(false); } base.Start(); mainMenu = avatar.expressionsMenu; parameters = avatar.expressionParameters; if (null == mainMenu || null == parameters) { TEA_Manager.SDKError($"Expression Menu [{null!=mainMenu}] or Parameters [{null!=parameters}]"); return(true); } root = CreateMainMenu(mainMenu, parameters); root.gameObject.SetActive(true); RadialPuppet.transform.SetAsLastSibling(); MultiAxisPuppet.transform.SetAsLastSibling(); _initialized = true; return(true); }
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(); }