void Deactivated(Panel_Base panel) { if (activeButton.linkedPanel) { if (activeButton.linkedPanel) { activeButton.ShowPanel(); activeButton.linkedPanel.panelActivatedEvent += ActiveButtonShown; } else { canswitch = true; } } else { canswitch = true; } //Remove from subscription if (previousActiveButton.linkedPanel) { previousActiveButton.linkedPanel.panelDeactivatedEvent -= Deactivated; } }
void ChangePanel(UserPanelButton previousButton, UserPanelButton currentButton) { previousActiveButton = previousButton; activeButton = currentButton; canswitch = false; if (previousActiveButton != null && previousActiveButton.linkedPanel) { if (previousActiveButton.linkedPanel) { previousActiveButton.HidePanel(); previousActiveButton.linkedPanel.panelDeactivatedEvent += Deactivated; } else { canswitch = true; } } else { if (activeButton.linkedPanel) { activeButton.ShowPanel(); activeButton.linkedPanel.panelActivatedEvent += ActiveButtonShown; } else { canswitch = true; } } }
//TODO: Consider disabling all the buttons if this goes out of hand void ChangePanel() { canswitch = false; //Debug.Log("Trying to change panel"); if (previousActiveButton != null && previousActiveButton.linkedPanel) { //Debug.Log("1"); if (previousActiveButton.linkedPanel) { Debug.Log("2"); previousActiveButton.HidePanel(); previousActiveButton.linkedPanel.panelDeactivatedEvent += Deactivated; } else { canswitch = true; } //Debug.Log("3"); } else { if (activeButton.linkedPanel) { //Debug.Log("4"); activeButton.ShowPanel(); activeButton.linkedPanel.panelActivatedEvent += ActiveButtonShown; } else { //Debug.Log("5"); canswitch = true; } //Debug.Log("6"); } //Debug.Log("7"); }