Need a code that can send you to the next scene when a button on-screen is pressed

So basically, I’m making a 3D game, and for the title screen I want there to be a button to go to the game when you click it. Being new to Unity, I don’t have the slightest clue of how to script that. Does anybody have a script I can use?

You can google for tutorials on changing scenes in Unity, as there are many available.

This will be the API you need:

I can’t seem to find anything so far.

I gave you the API for changing scenes above. Inside that documentation is actual example code.

I can only conclude you are not even trying. Have a nice day!

What a nice way to say “Screw you”

And I asked for a script that allows me to do it with the press of a button

The simple answer is you’ll need to find out how to hook code up to a button press. Unity UI buttons are fairly simple as they include a built in onClick. Since Start is an Autorun code, you’ll want to move the code outside start and then hook the new method with the load code up to your button.

The code itself isn’t any different other than it can’t be in Start. The rest is done in the inspector, so there isn’t any additional code to show you.

And how would I do that? The code, I mean.

You don’t need a lot of code for this.
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-Button.html
Simply create a UI button. There you can click the + below “On Click” and reference a script that contains a public method that should be called when the button is pressed.
@Kurt-Dekker already posted everything you need to make such a public method for loading a scene.

With an attitude like that, no one will help you now. Well done.

I think the misunderstanding in this thread is that OP didn’t know he can make a UI button without writing code.

These forums are not for “code requests”. They are to help one another learn to build games and solve problems. What you have asked is a very simple thing to do, something that you can do by putting in a little bit of effort with the documentation and learn section. If after that, you encounter problems, feel to post with questions. Closing for being a low-effort post.

1 Like