Home>

I am currently making a 2D RPG game using Unity.

While creating a status display for an RPG game using the Panel and Button of the UI, the following problem occurred.

-Duplicate the player character and status UI created in a specific Scene (Bar) to another Scene (OSIRO) by copying and pasting.
At that time, even if the status panel is opened in OSIRO, the UI button selection is not successful and the status panel cannot be operated.

Realization of the status panel/execution method on the game is as follows.
(1) Place the status created from Panel and Button of UI in Scene in the inactive state.
② Activate the status panel when Enter is pressed in the script of the player character (execute the script below by writing it in Updated())

region //Menu operation

if (Input.GetButtonDown("Menu")) // Assign the button name Menu to the Enter key and confirm that it was pressed
{
commandUI.SetActive(true);//Activate status panel
FirstButton1.Select();//Select the initial button on the status panel [Is there a problem? ]
GManager.instance.isStop = true;//Prohibition of player character movement while checking the status panel
}
if (Input.GetButtonDown("Cancel")) // Close the status panel with the cancel button
{
commandUI.SetActive(false);// Deactivate status panel
FirstButton1.Select();//Select the initial button on the status panel [Is there a problem? ]
GManager.instance.isStop = false;//Release movement prohibition of player characters while checking the status panel

}

endregion

The status of the bug is as follows
-It is possible to open the status panel from the Enter key, but the operation is impossible
・Cancel key can close the status panel
・No errors or warnings have occurred.

Especially, I would like to know how to select the UI button when switching the UI active/inactive
Which button is currently selected
Will be.

If there is a point that is difficult to understand, we will correct it if you point out, so we will correct it.
Thanks for your guidance and encouragement.

  • Answer # 1

    Is it impossible to click because it is inoperable?

    First, in Hierarchy of the relevant sceneEventSystemdo you have?
    If not right click>UI>EventSystemPlease create with.

    *I'm sorry if I misunderstand the intention of the question.