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 daviddickball · Jul 04, 2014 at 12:30 PM · scene-loadingscene-switchinglevel-design

Should an entire level be a prefab?

As far as ican see there's 2 ways to create different levels. Either save them as a scene, then load them using:

 Application.LoadLevel ("Level2"); 

But this might become cumbersome if I have many levels. I have to open them individually.

So the other idea was to save each level as a prefab and spawn the relevant one, and destroy the old when switching levels, but keep it within the same scene. What I want to check is that this is good practice? Is there an advantage of keeping levels in separate scenes? At least with the spawn/destroy method I can compare scenes side by side if needed.

I'd like to know your opinion, and possibly any link to tutorials if possible. Thanks!

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 meat5000 ♦ · Jul 04, 2014 at 12:55 PM 0
Share

Consider Additive Loading.

3 Replies

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

Answer by TonyLi · Jul 11, 2014 at 03:51 PM

Like @meat5000 writes, additive loading may be your best solution. I put together a free package and short tutorial on this at: http://www.pixelcrushers.com/scene-loader/

Not only can it take a long time to load a big prefab scene, but you can't nest prefabs, so you lose the advantages of prefab objects within the scene.

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
1

Answer by kannan21 · Jul 04, 2014 at 12:49 PM

If you load too much stuff in a single scene like you said most likely there will be a heavy performance issue. All of those objects will be in memory that is the main reason why we use scene system. If you put all the objects in one scene unity editor will keep crashing and the same happens to your game too. Instantiate is a really heavy function and so does destroy. So create separate scenes and iterate though them when ever it is necessary. But the things in your scene if they are very small in size and not heavy sized 3d objects you can keep all of them in one scene and you can enable and disable desired objects.

Comment
Add comment · Show 1 · 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 daviddickball · Jul 09, 2014 at 05:05 PM 0
Share

I assume loadLevel is pretty heavy too. I'd be loading the same assets whether I'm loading a scene, or just deleting the old prefab and instantiating another. Surely it'd be the same?

avatar image
0

Answer by MDarkwing · Jul 04, 2014 at 12:54 PM

Scenes are definitely better approach than instantiating whole level prefab which can be small (plane + few cubes, in which case it doesn't really matter) or ultra big (some castle environment with building, dungeons, trees, etc).

Another approach would be to have all the level prefabs in one scene then just enable/disable them correspondingly to what level do you need. This approach saves you trouble of data persistence throughout loading new scenes.

In my early days of development I would also put stuff in one scene but multiple scene is definitely good approach in most of cases.

On top of it all, I think you are missing the point of what prefabs are meant to be used. Prefab is a container to place some stuff you don't want to make again (in plain words). Example is you have some environment models: trees, rocks, grass, stumps, and you have to make a scenery out of it. It is more easy to make say 10 prefabs with different setting on them, then put those prefabs to make a scenery around a level, then to every time manualy put trees,rocks etc... This is the basic idea behind the prefab. Also one of the advantages of prefabs is, say now you want to make the winter setting of the map, and you have models that are covered in snow, but would be tiresome to put them all 1 by 1. You just get the prefab change the environment props in it, then save it and all objects based on that prefab will change also.

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 daviddickball · Jul 04, 2014 at 01:18 PM 0
Share

All of my scenes will have the same assets anyway. 3 types of asteroids, plus 4 invisible boundary walls. So the reason I suggested saving it as a prefab would be to contain it, so it can easily be instantiated or destroyed.

avatar image MDarkwing · Jul 11, 2014 at 10:57 AM 0
Share

Sry didn't see your comment on time. As I've said, you can do it whatever the way you see it fit, just instantiating and destroying the environment prefabs that can have lot of objects on them, can be performance costly. The technique you want to use is very subjective to your project type i would need more info to give you the best advice. For now, best solution that I see is to have scenes and prefabs. if you still want to have 1 scene, than make prefabs but dont destroy them, just enable/disable them based on what level you are playing.

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

7 People are following this question.

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

Related Questions

Switching between several levels 1 Answer

UnityEngine.SceneManagement contains no methods? 1 Answer

Help with loading scenes 2 Answers

Using parameters of activeSceneChanged? 0 Answers

Scene freezes after loaded 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