Hey, I am using the new Canvas thing and all, but I cannot figure out how to make a button when clicked do application.Quit(), do I create a script and add a function in MonoBehaviour? I tried that and there is no option for an event to do that when clicked.
Buttons can call functions that are in a MonoBehavior attached to an object. Create the method with Application.Quit() on a script attached to a GameObject. Click on the button in the Unity editor and go find the On Click() box. Click on the little plus sign and it will add an extra even. From there you can add the function. Change it to Editor and Runtime so it will function during testing. Under that there is a place to pick an object. It can be basically any object you want. Find the object you attached the script to. Now to the right you should see another menu. You can find the function you want in there.
I created the function in the script, I can even select the object and it’s attached script for the button’s OnClick() function, but when I do, I do NOT see the function I made for quitting the game. Any other suggestions?
Make sure the function is public.
Such a small mistake, I’m very sorry. But thank you. I have it fixed now.
No worries, that’s why we’re here.