- Home /
How to get the button Working?
Hi, I am making a main menu for my game, and I'm terribly new to Unity, I made a UI for the Main Men, I finally Created the Main Menu, ( i dont use scripts for i dunno how to make a lot of scripts for Im new, I have disabled the Free-Flight Menu GameObject and the Main Menu Gameobject activated, i want, when the free-flight button is pressed, that the main menu gameobject disables and The free-flight gameobject activated. When i attached the disabled Menu to the On-Click thing in the button they ask for a whole list of things like Transform, Gameobject, in those 2 Menu's they show a lot of Settings to choose, which one should i choose to Disable One GameObject and instantly Activate the other Gameobject (Disabling the Main Menu and Enabling the Free-Flight Menu, (When a button is pressed)
Answer by Devster2020 · Jun 29, 2021 at 09:13 AM
Hello @Chanindu!
The solution is simple:
Add to the button OnClick method, 2 action rows by clicking on the PLUS icon
In the first, drag the "MainMenu" gameObject, and in the second the "FreeFlight" gameObject.
In the "function" list, find "GameObject-->SetActive()"
Check the second, leaving unchecked the first.
Tadà!!!
@Devster2020 its not working at all, when i click the free-flight button it gets offed and the free-flight menu never activated, or if thats unable, how ought to i do it if the free-flight menu and main menu were 2 Different scene's,
and it only disables the main menu, i need the free-flight gameobject to get activated right after the MainMenu disables when the button is pressed
And i dont see the settings you see in my editor,
If the gameObjects to enable/disable are in 2 different scene, you CAN'T do it without coding.. Using a script is the only way..
If the objects are in the same scene, exchange their position.. first in the list the object to enable, and second the object to disable.
the objects ARE in the same, scene, i will try, thanks for your help
Answer by In0sc0p3dJFK · Jun 29, 2021 at 09:01 AM
this is going to need some scripting. it is not hard at all though. But you will need to be more specific in order for this question to be answered.