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
0
Question by Tipdude501 · Jun 05, 2014 at 03:25 AM · scenevariableload

Load Custom Scene

So I put a reload script on a plane beneath the level in case the player fell off, Just a really simple Application.LoadLevel script. This script can only be used for this one level though. Is there a way to make a customizable scene to load? In other words, does unity have a variable type for scenes? Thanks! alt text

screen shot 2014-06-04 at 11.11.47 pm.png (14.5 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

2 Replies

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

Answer by Tekksin · Jun 05, 2014 at 03:39 AM

in javascript it would be:

 var nextLevel : String; //make sure the s is uppercase. Unity sometimes likes to make it "string" instead of "String" (which matters)
 
 function Update(){
    Input.GetKeyDown("R"){
      Application.Load(nextLevel);
   }
 }

Go into your inspector and name the empty string variable (nextLevel) to whatever your desired next level's name is.

I'm pretty sure you don't want it to load a random scene, but rather a particular scene, but if you actually wanted something random to be loaded, you would assign the names of your other levels to numbers, and then do a random.range function. The number picked from random.range will correspond to the number that has been assigned to that level, and will load it up.

Comment
Add comment · Show 5 · 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 Tipdude501 · Jun 05, 2014 at 02:11 PM 0
Share

Exactly what I needed, thanks so much! :)

avatar image Tipdude501 · Jun 05, 2014 at 02:20 PM 0
Share

actually I'm now having an error when I use this; when I press play the character controller acts as though it's disabled and I can't control anything or move

avatar image Tipdude501 · Jun 05, 2014 at 02:32 PM 0
Share

I decided to use OnTriggerEnter ins$$anonymous$$d of Get$$anonymous$$eyDown and it works fine

avatar image Tekksin · Jun 05, 2014 at 10:25 PM 0
Share

hey, sorry, it might be because I made the R capitol lol. It should be lowercase "r". Try that if you want, and less us know if you are getting the same error.

avatar image Tipdude501 · Jun 10, 2014 at 08:21 PM 0
Share

Same issue

avatar image
0

Answer by Kiwasi · Jun 05, 2014 at 03:30 AM

Load level only takes string or int.

However if you know the name of the level you want to call you can do this:

 // You can dynamically change the value of nextLevel however you like
 string nextLevel = "TheNameOfTheNextScence";
 
 // This will call whatever level you have specified
 Application.LoadLevel (nextLevel);
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

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

23 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting variable as type "Scene" 4 Answers

My life counter is not updating 1 Answer

Loading Scene on a series of events 2 Answers

Load scene on button press 4 Answers

Loading player location in a 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