Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
7
Question by Chris 4 · Apr 17, 2011 at 05:24 PM · inputsceneloadloadlevelgetbutton

Load scene on button press

I have a script. I want it to load a scene when I push down a key. In this case the Space bar. However it does not work. I really do not know what is bad with it. I am new to unity scripting and I am pretty sure its just my script. Here is my code:

function Update() {
if(Input.GetButton("Jump")){
Application.LoadLevel (3);
}
}

Any help would be apreciated. :) Thank you.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
18
Best Answer

Answer by MC HALO · Apr 17, 2011 at 05:36 PM

Ok the script looks good to me but what you need to do is go to unity, click on file then build setting. Once you lick on build settings a menu will show up. In that menu there should be a field called "Scenes In Build", in this list you should have nothing. What you need to do is go to you "Project" view window and look for your scene once you find it drop and drop it on to your "Scenes In Build " window. Once you have done that the build view will add it to the list and on the side of the scene you will see a number 0 or 1. what this means is it has numbered the scene so like in your script you said load (3) that means the build will look for the number 3 and load that level.

the second thing is have you add this to your object if you have not it wont work.

and finally don't say:

Application.LoadLevel (3);

because in unity when you build a new scene and add it to the Build it will put this level above each other and it is one big problem.

instead use it like this :

 Application.LoadLevel ("Level1"); 

so instead of putting 1 put you scene name in there

hope this helped :)

Comment
Add comment · Show 7 · 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 Chris 4 · Apr 17, 2011 at 06:16 PM 1
Share

In a way you were right it was 2 although even so it did not do anything when I did change it. Also I tried to change it to the name of my scene and it did not work. (Got an error therefore not allowing me to play it...) I can post my ugly smelly old scene online to show you that it will not work. I am willing to try other things f you have other ideas.

avatar image MC HALO · Apr 17, 2011 at 11:15 PM 0
Share

And i am willing to help you please send me your project folder at my google mail account which is:

  Hummad.Nazir@gmail.com 

do not send it trough hotmail because it does nopt allow you to update huge files :) i look forward from hearing from you

avatar image MC HALO · Apr 17, 2011 at 11:17 PM 0
Share

opps i mean not lmao

avatar image p.margarida · Jul 04, 2012 at 01:59 PM 0
Share

That helped me a lot! :)

avatar image XanderX55 · Feb 28, 2013 at 04:17 PM 0
Share

So I need help to make it so that when I press a button that I created it goes onto the next scene. How would I do that?

Show more comments
avatar image
1

Answer by Uzquiano · Apr 17, 2011 at 05:35 PM

Hi,

Did you check the list of levels in the game? Use File->Build Settings

I mean, is there any level number 3?

Anyway, check the documentation if you didn't...

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
0

Answer by Guardian2300 · Jul 10, 2013 at 07:42 PM

Hello, Basically you write Application.LoadLevel("SceneNameDesired"); Then you have to go into Build Settings and drag the scene into the box with your current scene, should have two scenes after in build settings. Then it should work

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
0

Answer by Nabil_fx · Nov 06, 2014 at 07:27 PM

How can i attach this script to a touch Guibuttom?

Comment
Add comment · Show 1 · 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

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

8 People are following this question.

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

Related Questions

Input.GetMouseButton on multiple objects 1 Answer

Load / Stream 3rd Party Scene? 1 Answer

unity3D changingscene 0 Answers

Scene not loading properly everytime 3 Answers

Load Custom Scene 2 Answers


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