how to solve "Open Panel" and "Close Panel" is same button

Hi,
You can change the input used to open and close panels on this component which sits on the Canvas:
1662541914105.png

Unfortunatly I believe that using the same input for opening the main menu and closing panels will cause problems.
Because they are processed seperatly it can either reopen the menu that you just closed or close the menu as soon as it was opened.

So if you really want to have the same input for opening the main menu and closing panels you will need to replace this component by your own custom code. Fortunately that should be fairely simple as this component is simple.
The code is fully documented so you can read through it and see what you need to change.
Perhaps all it needs is an "else if" when checking the input such that it can only check one of the two inputs per frame.

(Code not tested)
Code:
//Close Panel
if (m_ClosePanelInput.CheckInput(m_PlayerInput)) {
    m_DisplayPanelManager.CloseSelectedPanel();
}else{
    //Open/Toggle Panel
    for (int i = 0; i < m_OpenTogglePanelInput.Length; i++) {
        if (m_OpenTogglePanelInput[i].CheckInput(m_PlayerInput)) {
            if (m_OpenTogglePanelInput[i].Toggle) {
                m_DisplayPanelManager.TogglePanel(m_OpenTogglePanelInput[i].PanelName);
            } else {
                m_DisplayPanelManager.OpenPanel(m_OpenTogglePanelInput[i].PanelName);
            }
        }
    }
}
I hope that helps
 
Also try Button Up (I don't own UIS but I assume it will have the option) as it'll never ever fire twice. Button Down should not fire more than once, but it is possible and known to happen, at least in my entire Unity experience if not others.
 
Hi,
You can change the input used to open and close panels on this component which sits on the Canvas:
View attachment 9550

Unfortunatly I believe that using the same input for opening the main menu and closing panels will cause problems.
Because they are processed seperatly it can either reopen the menu that you just closed or close the menu as soon as it was opened.

So if you really want to have the same input for opening the main menu and closing panels you will need to replace this component by your own custom code. Fortunately that should be fairely simple as this component is simple.
The code is fully documented so you can read through it and see what you need to change.
Perhaps all it needs is an "else if" when checking the input such that it can only check one of the two inputs per frame.

(Code not tested)
Code:
//Close Panel
if (m_ClosePanelInput.CheckInput(m_PlayerInput)) {
    m_DisplayPanelManager.CloseSelectedPanel();
}else{
    //Open/Toggle Panel
    for (int i = 0; i < m_OpenTogglePanelInput.Length; i++) {
        if (m_OpenTogglePanelInput[i].CheckInput(m_PlayerInput)) {
            if (m_OpenTogglePanelInput[i].Toggle) {
                m_DisplayPanelManager.TogglePanel(m_OpenTogglePanelInput[i].PanelName);
            } else {
                m_DisplayPanelManager.OpenPanel(m_OpenTogglePanelInput[i].PanelName);
            }
        }
    }
}
I hope that helps
thanks,i replaced by my custom component
 
Also try Button Up (I don't own UIS but I assume it will have the option) as it'll never ever fire twice. Button Down should not fire more than once, but it is possible and known to happen, at least in my entire Unity experience if not others.
yes, i solve this problem by this way
 
Top