Пример #1
0
        static public Button AddBasicToolButton(GameObject popupGO, string text, UnityAction onClickedF, Func <bool> isEnabledF = null)
        {
            GameObject buttonGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolButton"));

            popupGO.AddChild(buttonGO, false);
            buttonGO.SetName(text);
            Button button = UnityUIUtil.GetButtonAndAddClickHandler(buttonGO, onClickedF);

            UnityUIUtil.SetButtonText(button, text);

            if (isEnabledF != null)
            {
                var enabler = buttonGO.AddComponent <UIWidgetEnabler>();
                enabler.widget     = button;
                enabler.IsEnabledF = isEnabledF;
                enabler.Update();
            }

            return(button);
        }