public static RectTransform CreateStatIcon(string name, RectTransform template, Transform parent, Sprite icon, String hoverHintText = null)
        {
            RectTransform statIcon = UnityEngine.Object.Instantiate(template, parent, false);

            statIcon.name = name;
            (statIcon.transform as RectTransform).Translate(0, -0.1f, 0);
            BeatSaberUI.SetStatButtonIcon(statIcon, icon);
            BeatSaberUI.DestroyHoverHint(statIcon);

            if (!String.IsNullOrEmpty(hoverHintText))
            {
                BeatSaberUI.SetHoverHint(statIcon, $"{name}_hoverHintText", hoverHintText);
            }

            return(statIcon);
        }
Example #2
0
        /// <summary>
        /// Create an icon button, simple.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="buttonTemplate"></param>
        /// <param name="iconSprite"></param>
        /// <returns></returns>
        public static Button CreateIconButton(RectTransform parent, Button buttonTemplate, Sprite iconSprite)
        {
            Button newButton = BeatSaberUI.CreateUIButton(parent, buttonTemplate);

            newButton.interactable = true;

            RectTransform textRect = newButton.GetComponentsInChildren <RectTransform>(true).FirstOrDefault(c => c.name == "Text");

            if (textRect != null)
            {
                UnityEngine.Object.Destroy(textRect.gameObject);
            }

            newButton.SetButtonIcon(iconSprite);
            newButton.onClick.RemoveAllListeners();

            return(newButton);
        }
        public static Button CreateIconButton(this HMUI.ViewController parent, string name, string buttonTemplate, Vector2 anchoredPosition, Vector2 sizeDelta, UnityAction onClick, Sprite icon, string hint)
        {
            Button btn = BeatSaberUI.CreateIconButton(name, parent.rectTransform, buttonTemplate, anchoredPosition, sizeDelta, onClick, icon, hint);

            return(btn);
        }
        public static Button CreateUIButton(this HMUI.ViewController parent, string name, string buttonTemplate, Vector2 anchoredPosition, Vector2 sizeDelta, UnityAction onClick = null, string buttonText = "BUTTON")
        {
            Button btn = BeatSaberUI.CreateUIButton(name, parent.rectTransform, buttonTemplate, anchoredPosition, sizeDelta, onClick, buttonText);

            return(btn);
        }
Example #5
0
        public static Button CreateBackButton(this HMUI.ViewController parent)
        {
            Button btn = BeatSaberUI.CreateBackButton(parent.rectTransform);

            return(btn);
        }
Example #6
0
        public static Button CreateUIButton(this HMUI.ViewController parent, string buttonTemplate, UnityAction onClick = null, string buttonText = "BUTTON", Sprite icon = null)
        {
            Button btn = BeatSaberUI.CreateUIButton(parent.rectTransform, buttonTemplate, onClick, buttonText, icon);

            return(btn);
        }
Example #7
0
        public static Button CreateUIButton(this HMUI.ViewController parent, string buttonTemplate)
        {
            Button btn = BeatSaberUI.CreateUIButton(parent.rectTransform, buttonTemplate);

            return(btn);
        }
Example #8
0
        public static TextMeshProUGUI CreateText(this HMUI.ViewController parent, string text, Vector2 anchoredPosition)
        {
            TextMeshProUGUI textMesh = BeatSaberUI.CreateText(parent.rectTransform, text, anchoredPosition);

            return(textMesh);
        }