コード例 #1
0
    public bool RemoveButton(Button buttonComponent)
    {
        buttonComponent.onClick.RemoveListener(OnButtonClicked);

        if (SelectedButton == buttonComponent)
        {
            SelectedButton = null;
            SelectedButtonChanged.Invoke(SelectedButton);
        }

        return(Buttons.Remove(buttonComponent));
    }
コード例 #2
0
    /*Private methods*/

    private void OnButtonClicked()
    {
        //We know its worker list button because its clicked event has been just called
        GameObject selectedButton  = EventSystem.current.currentSelectedGameObject;
        Button     buttonComponent = selectedButton.GetComponent <Button>();

        if (buttonComponent != SelectedButton)
        {
            SelectedButton = buttonComponent;
            SelectedButtonChanged?.Invoke(buttonComponent);
        }
    }