Ejemplo n.º 1
0
        // -------------------------------------------------------------------------------
        public virtual void Init(UIButtonGroup _buttonGroup = null)
        {
            button.onClick.RemoveAllListeners();

            if (delayDuration <= 0 && _buttonGroup == null)
            {
                return;
            }

            buttonGroup   = _buttonGroup;
            _interactable = button.interactable;

            if (buttonGroup)
            {
                buttonGroup.Add(this);
            }

            button.onClick.AddListener(() =>
            {
                if (buttonGroup)
                {
                    buttonGroup.OnPressed(this);
                }
                else
                {
                    OnPressed();
                }
            });
        }
        // -------------------------------------------------------------------------------
        // Init
        // -------------------------------------------------------------------------------
        public void Init(UIButtonGroup _buttonGroup, int index, string name, bool _selected = false)
        {
            selected = _selected;

            base.Init(_buttonGroup);

            _index        = index;
            textName.text = name;

            if (selected)
            {
                imageSelected.sprite = selectedImage;
            }
            else
            {
                imageSelected.sprite = unselectedImage;
            }
        }