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 omegasoft · Dec 22, 2012 at 12:29 PM · scenecharacterdestroyload

How can i load may last scene without load duplicate?

hi everybody

i made a main scene and i want character go to another scene and back to the main scene. in the mainscene i have an object and i need it during of the game and i used "Dont destroy OnLoad".when i am loadind my main scene again my object (witch i made it for "Dont destroy OnLoad") is loading again. how can i stop it. i dont want that object be loaded again.

Please Help me Thanks

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
6
Best Answer

Answer by Bunny83 · Dec 23, 2012 at 12:46 AM

The easiest and most robust way is to use another scene, a loader scene which you only load once at the start. This scene contains your persistant objects which mark themselfs with DontDestroyOnLoad. All you do in this scene is loading the mainmenu scene immediately at start. Never load the loader scene again since that's the point of it ;)

Comment
Add comment · Show 2 · 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 omegasoft · Dec 26, 2012 at 01:58 PM 0
Share

i did it. i made another scene and in the first it was good but now i have another problem. i am loading this scene and am spawning new character in network. now when i am spawning new character, first character is ok but next character cannot see characters before that it. and next one cannot see 1 and 2!!! what i have to do with this problem now? please help. thanks

avatar image bruno-ribeiro · Mar 25, 2017 at 10:31 AM 0
Share

So simple and clever! Helped me a lot, thanks!

avatar image
0

Answer by liszto · Dec 23, 2012 at 12:42 AM

if it's an object from your main scene it's normal because when you destroy your scene to load another one, your object is not destroy but the scene always got one in this hierarchy. So when you load this scene again, this scene load it again with her.

To avoid this, you must check in the Awake function if your object already exists in your current scene and if yes just delete it (the new one).

Or other method is to instantiate this object in a script of your main scene (your character is probably a prefab). At start of this script so when you main scene is just loaded, the start function gonna check if your object already exists in the current scene (check with the method of your choice) and if it's yes just don't instantiate it. (I prefer this method ;) )

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 ownerfate · Aug 13, 2013 at 12:49 AM

this might be what you were going after, i know it's a very very late comment but if you are still looking.

http://answers.unity3d.com/questions/34185/dontdestroyonload-is-it-intended-behavior.html

duck ♦♦'s script is what i have been searching for... all this time.

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

13 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

Related Questions

Dont Destroy On Load Scene Return Problem 1 Answer

Random level select 1 Answer

Loading player location in a scene 2 Answers

Creating and destroying password stage between scenes 0 Answers

When I start my game again the destroyed turrets are still not there 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