Ejemplo n.º 1
0
        public static Button CreateButton(string title, Transform parent, Action action, string sound = "click")
        {
            Button act = Instantiate(UIElements.Get().button, parent).GetComponent <Button>();

            UpdateButtonText(act, title);
            //act.transform.Find("Label").GetComponent<Text>().text = TextHelper.Cap(title);
            act.onClick.AddListener(() => {
                try
                {
                    action();
                }
                catch (Exception e)
                {
                    ExceptionHelper.ShowException(e);
                }
            });
            UIElements.AddButtonSound(act, sound);
            return(act);
        }
Ejemplo n.º 2
0
        public static Button CreateImageTextButton(string title, Sprite icon, Transform parent, Action action, string sound = "click")
        {
            Button act = Instantiate(UIElements.Get().imageTextButton, parent).GetComponent <Button>();

            UpdateButtonText(act, title);
            //act.name = title;
            //act.transform.GetChild(0).GetComponent<Text>().text = TextHelper.Cap(title);
            act.transform.GetChild(1).GetComponent <Image>().sprite = icon;
            act.onClick.AddListener(() => {
                try
                {
                    action();
                }
                catch (Exception e)
                {
                    ExceptionHelper.ShowException(e);
                }
            });
            UIElements.AddButtonSound(act, sound);
            return(act);
        }