Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 npruehs · Oct 04, 2011 at 01:35 PM · objectsceneloading

Prevent Object From Loading

Hello everybody,

I worked my way through Unity's Execution Order at http://unity3d.com/support/documentation/Manual/Execution%20Order.html and wondered whether there is a possibility of preventing a given object from loading at the start of a scene.

To be more specific: My game requires scene transitions that return to previous visited scenes again and again. Some of these objects might have been destroyed in between, but would be loaded again as soon as the player returns. Our idea is to save the game state in form of conditions to a specific Manager object that has DontDestroyOnLoad called at the beginning of the game.

Next step would be to destroy these objects in Awake if these conditions hold true, but I'd prefer not even loading them... Any ideas?

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

Answer by syclamoth · Oct 04, 2011 at 01:37 PM

Ususally for this kind of thing, I make an empty "void" scene which only contains the important stuff which shouldn't get destroyed between levels (player info, game engine stuff), load it first, and then immediately load the actual scenes after setting 'DontDestroyOnLoad' for all my game engine stuff. I then never go back to the initial scene unless I want to do a full reset, in which case I manually delete the game engine bits, and reload from level 0.

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 npruehs · Oct 04, 2011 at 02:47 PM 0
Share

Yes, so do we. But how do I prevent parts of the "actual scenes" from being loaded? I'll add an example:

We have a scene A that contains the main character and his dog. His dog dies. The main character moves on to scene B. Having done some stuff there, he returns to scene A and his dog would be there again, because it was part of the Unity scene file.

avatar image syclamoth · Oct 04, 2011 at 10:07 PM 0
Share

In your important game-engine stuff, have a variable with 'isDogDead', which your game queries when it would spawn a dog. To get around this stuff, I always instantiate prefabs for players etc. when I load my levels!

avatar image
1

Answer by npruehs · Oct 05, 2011 at 09:12 AM

Alright - but this approach has another drawback: Desingers and level artists are unable to check their work without starting the game over and over again...

Anyway, thanks for the answers! :)

Comment
Add comment · Show 7 · 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 NickVraa · Nov 18, 2015 at 12:37 PM 0
Share

This is exactly the problem i'm having. I would like an answer too.

avatar image ijidau · Nov 18, 2015 at 01:04 PM 0
Share

Have the object in the scene hierarchy, but destroy on load if it should not be there.

avatar image NickVraa ijidau · Nov 18, 2015 at 01:17 PM 0
Share

Yes, but this requires that they have been loaded into the scene in first place, which takes time, and that is exactly what we're trying to avoid.

Otherwise, there is no point in having a load scene in the first place.

avatar image ijidau NickVraa · Nov 18, 2015 at 01:20 PM 0
Share

Oh right, I see... perhaps this will help: http://docs.unity3d.com/ScriptReference/Application-isEditor.html

e.g. Instantiate depending on if the object should be loaded, or if in the editor just override as you wish.

Show more comments
Show more comments
avatar image Bonfire-Boy · Nov 18, 2015 at 04:03 PM 0
Share

Shove the stuff in a prefab. When running the game, your first scene as per syclamoth's answer (I call that a 'bootstrap' scene) instantiates the prefab. Designers and level artists can check (and work on) their work in Edit mode, in any scene, by just dragging the prefab in, editing it, and applying changes.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

heavy scene loading 1 Answer

pre-load multiple scenes but only activate one 0 Answers

Addressable for Oculus Go 2 Answers

Save & Load Game question 3 Answers

Unity2020 loads project but unable to edit 0 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