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 Firus_HNTR · Dec 26, 2014 at 10:42 PM · javascriptscene-loadingnoob

Call previous level, as for whatever it was

Hey guys
So lets say there is 5 scenes in the game, and I jumped from 1 to 4, then I set a trigger for the 4th scene to call the previous one (which is 1) but instead of calling the scene 1 it calls scene 3. Whatever scene it was before scene 4 is the one I want to show up. How can I fix that?

 Application.LoadLevel(Application.loadedLevel-1);

Thank you for the help.

Comment
Add comment · Show 3
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 richyrich · Dec 27, 2014 at 10:12 PM 1
Share

Not something I've needed to do, but it'll probably work:

Just before you make a call to LoadLevel, set a variable in another gameobject's script to whatever the current level is.

When you load the next level, you can then access the number of the previous level using the mechanism above. In order for this to work, you would need to maintain state between levels, see also http://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html and http://answers.unity3d.com/questions/747603/how-does-dontdestroyonload-work-1.html

avatar image fafase · Dec 27, 2014 at 10:59 PM 0
Share

if you can open new scene each time and get back to the previous then you need stack. for instance, you are in 1, go to 4, then from 4 to 3 and now you want back to 4 and from 4 to 1. for this you need to store in a stack.

you can actually remember as many as you want and even store multiple times the same scene creating complex puzzles.

avatar image Firus_HNTR · Dec 27, 2014 at 11:43 PM 0
Share

I will try to do that, but I'm not sure if it is going to work. Because the thing is, there is 3 levels that brings to level 4, and it is totally random, so what I wanted to do is lets say, If 1 is to 4, bring 4 to 1, if 2 is to 4 bring 4 to 2 and so on. So I will stack the info in a script and do dontdestroyonload and lets hope it will work. I will get back to you guys to put the results.

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Extreme Beginner Scripting Question 2 Answers

How does Unity "read" JavaScript code? 3 Answers

Help With "Scripting" 1 Answer

Camera movement(I have no clue how to code) 0 Answers

how to disable a script component 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