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 Fattie · Oct 11, 2011 at 12:17 PM · prefabsloadingscenesdontdestroyonload

Confusion about DontDestroyOnLoad and very large scenes...

Say you have two scenes, #11 and #12, with huge load time (say 30 seconds load time).

scene 11 .. contains an enormous object "Island", and a few other things

scene 12 .. contains the identical enormous object "island", and a few other things

Say you've just loaded and used scene #11. You now want to change to scene #12.

it seems ridiculous to re-load the "island" object again. Is this exactly what DontDestroyOnLoad does?

My question: if inside #11 you set "island" (and that is inside #11) as DontDestroyOnLoad, then, once #12 loads,

in fact is the island in #12 now the "same" island as we just had in #11?

is that exactly correct? Does anyone know?

Follow-up question: once #12 is loaded, does "island" return to it's original state (as when #11 first loaded)? Or, is it "unchanged" from the moment of changeover -- ie all the variables and so on have whatever values they have when you called for the loading of #12.

I realise this question is in the lame "couldn't you just try it?" category :)

By the way, I completely understand that you can just load the island, and then drop in the various "other stuff" to create scenes like 11 and 12. But it is incredibly better workflow if the teams can just work on their own scenes. I absolutely understand how to do it "manually", I am looking for an answer to the question written above, if anyone knows, thanks.

Tricky follow-up question: Say scene #12 does NOT happen to include the "island". (i.e., you have pointlessly, perhaps accidentally, marked the "island" as DontDestroyOnLoad in #11 .. but in fact you are not even using it in #12.) In fact, in that case, what the hell happens to the "island"? Does it just hang around in memory - but not part of scene #12 currently playing? Or does it force itself in to scene #12 (presumably at the same transform position) ... or what???

Final follow-up question Do you have to do anything in scene #12, to let scene 12 know that it should "not load" "island", since island will already be there? Or, will in fact scene #12 (completely pointlessly) load "island" again anyway? Or in fact, do you have to not include "island" in scene #12? Or what??

if anyone can answer the four questions, 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

1 Reply

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

Answer by syclamoth · Oct 11, 2011 at 12:30 PM

When you load the scene, Unity does not know that the 'huge island' is in fact identical to the one already in the scene- you will end up with two instances of the same huge object! The load times will remain. There will be a 'new' island, which is in 'mint condition', and in the same spot as your old island.

I think the main answer to all of your question is that all 'DontDestroyOnLoad' does is prevent Unity from deleting those specific objects upon scene loading. If your new scene doesn't have the island in it, the island will stay, (and probably look pretty weird in the middle of your new scene).

In my opinion, you should have the island in one scene, which gets loaded first, and then use LoadLevelAdditively to put in scenes with all the new content in it. If you have your island duplicated, that's how it will end up- Unity has no way of knowing that you don't want two of that huge island in your game! (it's kind of stupid like that).

Doing it that way has the disadvantage that each 'subscene' doesn't get to see the island when it's getting assembled (unless you do something clever like put a super-low-res 'proxy' island in, which gets deleted upon scene load in an Awake() script). But the advantage is that you only have to load large assets once, and only delete them when you want to move on to a totally new scene using LoadLevel (not additively).

Comment
Add comment · Show 3 · 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 Fattie · Oct 11, 2011 at 02:07 PM 0
Share

@Sycla, thanks a million for the clear answer. Awesome. Regarding what you said about workflow: Would this work: in scene 12, have the full island there during work in progress. When you build, simply, just deactivate the island in scene 12. IE simply uncheck the small check-box at the extreme top left of the Inspector. If you have that checkbox "off" -- it does not even load as an asset .... is that correct? Alternately is there some other programmatic way to NOT load an object of a scene? (perhaps a whole other question there!) Thanks again!!

avatar image syclamoth · Oct 11, 2011 at 02:15 PM 0
Share

As far as I can tell, there's no way of stopping an object from being loaded. You have to load the objects before you can act on them! I'm pretty sure deactivating it before build would work the way you want it to- have a look at build pipeline scripting if you want to do it automatically! (I don't know anything about that, other than that it is possible...). Test it all, of course- this isn't really something I've ever done, (the humungous single asset thing, that is, I've done plenty of level loading), so you'd have to test it all before committing to anything.

Having thought about it a bit more, I'm convinced that having a super-low-detail island to work on (which gets deleted upon level load or before build, whatever you can do) would have to be the best in terms of work-flow. As long as your level designers don't need perfect detail in order to do their work.

avatar image Fattie · Oct 11, 2011 at 04:03 PM 0
Share

Good one, thanks! You know, a very simple pipeline solution is, simply, just $$anonymous$$ETE the island in #12 before you build. that works perfectly. so long as it's easy to put it back in again for the next round of development (normalise the coords using a holder to 000). That would work fine. I'm gonna go check if it ACTUALLY LOADS an object which is $$anonymous$$AR$$anonymous$$ED INACTIVE -- I fear it probably does. Thanks again!

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

access a gameobject from another scene at design-time 2 Answers

How to keep assets in memory without duplication? 1 Answer

Walking between scenes 1 Answer

Shared canvas for some scenes 1 Answer

LoadLevelAsync coroutine reloads level repetedly 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