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
1
Question by user-12299 (yahoo) · May 04, 2011 at 01:54 PM · screentransition

transition between scenes

Hi everybody!

Maybe i is a really stupid question but i'm tortaly new to unity.... I have a scene with abuilding that has an infodesk.The infodesk has a simple button that when pressed a new scene opens and the user can see the screen and interact with it.My prloblem is tha i need to create a button that when the user exits this scene he returns in the previous scene but exactly in the place he was before. Right now he returns in the main scene but in the entrance of my building and not in front of the infodesk...Thank you!

Comment
Add comment · Show 1
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 Aldwoni_legacy · May 04, 2011 at 02:02 PM 0
Share

Can't you make a variable which keeps the positioninformation when you leave a scene? When you go back you ask the variable where to place the user?

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by Alec-Slayden · May 04, 2011 at 02:03 PM

There's a couple ways to do this.

One way is to save the player's position to a variable on an object, along with DontDestroyOnLoad To keep it in existence in the new scene. This is good especially if you have various forms of data you might like to keep and reference across multiple scenes, or if you want sounds to continue playing, etc.

Another way is to make use of PlayerPrefs to store and retrieve data between scenes. This is particularly useful for communicating data across any scene order, or even temporarily saving information for return visits.

Edit: Clarification of DontDestroyOnLoad

This function is called in a script on the object you want to keep, telling Unity not to delete it, if another scene is loaded.

if you created an empty game object, you could put a script like this on it (javascript here):

static var savedPosition : Vector3;

function Awake(){ DontDestroyOnLoad(transform.gameObject); }

Unity will see your DontDestroy function as soon as the script awakens, and the object and the variable on its script will continue into any scenes that you load afterward.

since the savedPosition variable is static, you can reference it from any script easily, including setting it's value just before loading a scene.

one of the strengths of this method is that DontDestroyOnLoad protects its hierarchy, so you could, in theory, parent other objects to it interactively if you want them to endure to the next scene also.

Comment
Add comment · Show 6 · 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 by0log1c · May 04, 2011 at 02:14 PM 0
Share

Recommended answer ;)

avatar image user-12299 (yahoo) · May 04, 2011 at 03:23 PM 0
Share

Thank g=for your answer Alec,

Can you please explain a bit more the how can i implement the first option?I'm not sure how to use the application.Loadlevel with DontDestroy.. $$anonymous$$aybe you can give me an expample?

avatar image Alec-Slayden · May 04, 2011 at 04:43 PM 0
Share

edited for clarity

avatar image user-12299 (yahoo) · May 09, 2011 at 06:43 PM 0
Share

i'm going crazy with this....i use this function and when i return to my main scene the player seems like falling from the scene...what do i do wrong?

avatar image Alec-Slayden · May 09, 2011 at 08:12 PM 0
Share

Sounds like a collider issue. $$anonymous$$ake sure it's not sticking through the terrain / floor when he comes back. $$anonymous$$ake sure he's not moving much when he comes back also, because of the problems with moving platforms and the player controller.

Show more comments

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

1 Person is following this question.

avatar image

Related Questions

Fade Screen Transition After Death 1 Answer

Trouble with "Creating Screen Transitions" UI How To 0 Answers

Where does GUI end up? 1 Answer

how to get a window bigger than screen 0 Answers

Fixing screen resolution 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