public bool RemoveButton(Button buttonComponent) { buttonComponent.onClick.RemoveListener(OnButtonClicked); if (SelectedButton == buttonComponent) { SelectedButton = null; SelectedButtonChanged.Invoke(SelectedButton); } return(Buttons.Remove(buttonComponent)); }
/*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); } }