Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Dav36id · Apr 24, 2015 at 12:43 PM · menu

Button OnClick load scene

Hi! Im trying to create a simple menu. Im adding a Button but I dont know how to OnClick load game scene (I call it Main).

How I can do it? Thanks!

alt text

button.jpg (19.0 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by Landern · Apr 24, 2015 at 12:45 PM

Go and watch the UI.Button tutorial. After you watched and created your script that will eventually be attached the OnClick event you will want to put in your event one of two Application methods.

Application.LoadLevel(String) which will load a scene by it's name in the build settings or

Application.LoadLevel(int) which will load the scene by the index value in the build settings.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
3

Answer by Amoldadu · May 15, 2017 at 07:15 AM

@Dav36id you can also do it without using script... just in a simple way like thisalt text

The 1 is the scene number which you want to load... you can see scene numbers in File-> Build setting Thank u


snip.png (9.9 kB)
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SpockderPants · Aug 17, 2017 at 06:25 AM 1
Share

I've been searching for a while, I don't have the LoadOnClick.LoadScene option by default, where do I get this? alt text

example.png (8.6 kB)
avatar image Newclen SpockderPants · Sep 14, 2017 at 09:53 PM 0
Share

I have this problem too! If you've figured it out how to solve it, then can you please tell me?

avatar image venomtail · Aug 06, 2021 at 04:55 PM 0
Share

There is no such option. Unless you make and reference a script which your icon indicates that you have a script referenced.

avatar image
3

Answer by $$anonymous$$ · Oct 05, 2017 at 08:07 AM

I'm not sure if you can do it without a script... In Amoldadu's screenshot, there appears to be a script attached...

Anyway, loading a scene on a button click isn't that hard at all. There are two ways you can load scenes - by name, or by number.

In Javascript (by name):

 #pragma strict
 import UnityEngine.SceneManagement;
 function LoadLevel()
 {
     SceneManager.LoadScene("gameplay");
 }

And in C# (by number) - remember to call this 'SceneLoader.cs':

 using UnityEngine;
 using System.Collections;
 
 public class SceneLoader: Monobehaviour {
 
      public void LoadScene(int level)
      { 
         Application.LoadLevel(level);
       }
 }

Make sure that all your scenes are chronologically ordered in your build settings. Create an empty gameObject and drop your new code in. Drag this gameObject into the placeholder in your button inspector. You should find a 'LoadLevel()' function (or something similar) in the dropdown menu.

I'd be very surprised if there was a scriptless scene loader button...

Hope I helped :)

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AustrianMappingOfficial · Feb 05, 2019 at 05:10 PM 0
Share

Honestly I have no idea what you talked about... Well, that's the problem when you're a beginner and english isn't your first language. RIP

avatar image mman10 · Dec 15, 2019 at 12:33 AM 0
Share

There was a slight typo in his answer.

 using UnityEngine;
 using UnityEngine.Scene$$anonymous$$anagement;
 
 public class SceneLoader : $$anonymous$$onoBehaviour
 {
 
     public void LoadScene(int level)
     {
         Scene$$anonymous$$anager.LoadScene(level);
     }
 }

avatar image mman10 mman10 · Dec 15, 2019 at 12:41 AM 0
Share

Don't forget to name the script in this case SceneLoader.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to i make it use animation on camera only after clicking? 1 Answer

Main Menu button in pause menu 0 Answers

Simple menu problem 2 Answers

How can I make the in-game menu remains unchange while changing scenes? 3 Answers

Help with input code please (c#) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges