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 CrazyPizza · Nov 05, 2013 at 09:54 PM · androidinstantiateloadlevelscene-changelevel-design

Load Scene. Efficiency question

Hello, I'm making a simple puzzle game (Android) where you have to tap on squares and they rotate; my scene is composed by a plane (to show the background image) and 9 squares in a grid.

I instantiate the squares in Start() with an algorithm. Now my question is: if I want to change to another level, is it more efficient to make a scene for every level and use Application.LoadScene() or wipeing the squares grid and instantiate a new one? (When I LoadScene() does the active scene shut down completely or does it stay frozen somewhere?)

Thanks for your attention ;)

Comment
Add comment · Show 2
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 Tomer-Barkan · Nov 06, 2013 at 01:09 PM 0
Share

I think you mean Application.LoadLevel(), couldn't find any LoadScene in unity documentation...

As you can read in the documentation here, LoadLevel() destroys all loaded objects and loads the new ones from the scene you're loading. It's probably more efficient than destroying the objects one by one, and since you have to load the new objects from scratch anyway, I don't see any reason to write the more complex code... just use LoadLevel(). If you want to really be sure, do some tests and check which is faster, and by how much.

avatar image CrazyPizza · Nov 06, 2013 at 06:18 PM 0
Share

Yes I meant LoadLevel(). I'll do some tests and see ;)

3 Replies

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

Answer by rutter · Nov 05, 2013 at 10:23 PM

is it more efficient to make a scene for every level and use Application.LoadScene() or wipeing the squares grid and instantiate a new one?

Depends what sort of efficiency you're talking about. You can spend a lot of time optimizing your game, but it's not always the best place to start.

I'd get the core gameplay working, first, and then improve performance from there. This list includes a few steps I might go through for any given feature; the top of the list is usually easier to develop, the bottom of the list usually yields better run-time performance:

  • Reload the entire level, start from scratch each time.

  • Reset the scene: delete key prefabs, instantiate new ones.

  • Reset the scene: reset or recycle prefabs, destroy/instantiate as needed.

  • Reset the scene: use object pools, avoid Instantiate() and Destroy() whenever possible.

Reducing the length and frequency of level loads will keep your player in the game. Reducing the build size will get them into it more quickly. This matters more on some platforms than others (WebPlayer download time matters quite a lot more than standalone PC builds, for example).

It's not always feasible to create levels dynamically. Maybe you need static lighting. Maybe designers need to be able to tweak certain scenes or events. Unity's build process can optimize load times quite a bit, if you let it know what assets are actually going to be used.

When I LoadScene() does the active scene shut down completely or does it stay frozen somewhere?

Application.LoadLevel() will generally destroy and unload all GameObjects in the current scene, excepting those that are marked with Object.DontDestroyOnLoad().

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 CrazyPizza · Nov 06, 2013 at 12:33 PM 0
Share

Thanks a lot for the answer! I'll evaluate what is best for my game

avatar image
0

Answer by Point blank interactive · Nov 05, 2013 at 10:10 PM

I'm pretty sure when you LoadScene(), it restarts the scene, and loads the specified one.

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 Point blank interactive · Nov 05, 2013 at 10:10 PM

It would be more efficient to instantiate a new one. It would be extremely obnoxious to make hundreds of scenes for randomized levels.

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 CrazyPizza · Nov 06, 2013 at 12:35 PM 0
Share

That's true. That's why I made an algorithm that instantiate the squares according to a scheme taken from a String; I was sure it would have come in hand

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

18 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Instantiate a sprite using json data value (C# Unity) 2 Answers

Apply Configuration Files/Custom Stored Assets when Selecting a Level? 0 Answers

Can not get Level to Load using level collider 1 Answer

How to load a level after 30 seconds? 3 Answers

Application.LoadLevel Strange Problem 2 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