I have 4 buttons on the screen that are represented by a default image. Clicking on any of the buttons will bring up a corresponding menu:
Button 1 brings up Menu 1, Button 2 brings up Menu 2, etc. These menus would only be accessible by their respective button and can’t be influenced by any other.
These menus contain more buttons represented by unique images. Clicking on any of these images will close out of the menu and return you to the 4 buttons. However, whichever button you clicked on will now have the image you chose from the secondary menu instead of the default:
Button 1 is clicked and brings up Menu 1. You choose Image 2, which closes out of Menu 1. Button 1 now has Image 2 as its image.
Question:
Would anyone be able to point me in the direction of a tutorial that could help with this or information on how to do this?
I appreciate any information you can provide in regards to doing this. Thanks in advance.
make 4 buttons. make gameobjects for other menus which have other child-buttons (one button for one image). Disable this gameobject in the inspector. On the first four buttons add script and event with IsClicked function:
public GameObject hiddenMenu;
public Button firstSelectedButton;
public void IsClicked()
{
hiddenMenu.SetActive(true);
firstSelectedButton.Select();
}
In its field place disabled menu object and its button. Now the click on one of four buttons should open one menu and select its button (adjust the navigation in the inspector to acces other buttons in this menu).
On the hidden menu add script to the buttons:
public Button firstSelectedButton;
public Image linkToImageFromButtonOfMainMenu;
public Sprite newImageForTheButton;
public void IsClicked()
{
firstSelectedButton.Select();
linkToImageFromButtonOfMainMenu.image = newImageForTheButton;
gameObject.SetActive(false);
}
Click on the button should switch the image on the main button, select it and close the second menu.
First off, thanks for the reply. I have attempted to implement your solution, but I guess I’m doing something wrong since I can’t get the button to disable the specified GameObject.
My setup:
I have a button called MenuOneButton. This is the button that should activate Menu One. I then created a Panel called MenuOne and this panel contains several buttons. I assigned the MenuOne panel to the GameObject field on the MenuOneButton and then I disabled the panel. However, when I click MenuOneButton, nothing happens. Am I understanding you incorrectly or am I just doing something wrong?
do you have add onClick event to the button ?
In buttons inspector there is by default “On Click()” empty list for events. Add new event (click on +), then put your button in the “none” field and add which function should be startet on click (this can be public function from your script on this button. In my example “IsClicked()”).