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 AndersonDev · Jun 29, 2016 at 05:44 PM · uiloadlevellevels

Levels changing with UI best practice

I have a game with many levels. Hovewer on each level I have the SAME UI (buttons bause, health, ect.). Here is some BEST practice to realize scene loading with UI saving?

Levels as scenes? Or other way? I have realized loading levels from prefabs, but It was not best idea... I also can put same ui in each level...

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by hyperi0n · Jun 30, 2016 at 12:08 PM

"DontDestroyOnLoad" sounds like something that might interest you:

https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html

However, it will probably not just work like magic - you will have to be careful when UI elements refer to objects (e.g. the player) that DO get destroyed when loading a new level.

So you would probably have to have some kind of script that resets the UI after a level change, fixing references to objects, resetting values etc.

However, it may still be better than creating/copying the UI in every level scene, because then when you want to make changes, you will have to do it in every scene. So I guess using don't destroy on load would be better.

As an altrnative, you could also make a prefab out of your UI and simply instantiate it after a level has been loaded.

Regarding what system to use (scenes/prefabs) for changing of levels, that depends alot on the kind of game you are building. If its e.g. a shooter where the levels must be hand built in advance, scenes is probably the way to go. If you have a simple puzzle game like breakout, then building the scene out of prefabs via a level-generator script may be better.

I hope this helps! Good Luck!

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 AndersonDev · Jul 01, 2016 at 11:11 AM 0
Share

I realy know about DontDestroyOnLoad=)

However I need to thome best practice. Some advice from guys who make It in own game. DontDestroyOnLoad - ok. But if I go to main menu or level selecting I need to delete UI.

I have wariant to have some scene only with UI, put all in prefab and spawn on each level. I have some arcade with level selecting, store end levels.

Thanks!

avatar image
0

Answer by DroidifyDevs · Jun 30, 2016 at 01:19 PM

use DontDestroyOnLoad for the UI.

As for the levels, I don't know what game you're making, but I'd do one of these:

1: Make different scenes for each level 2: Make a script to spawn objects for every level.

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 AndersonDev · Jul 01, 2016 at 11:11 AM 0
Share

I left coment in post above. Thanks!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to call a button to specific levels without using the OR (||) function? 1 Answer

Change level after ''X'' seconds 2 Answers

Clear presses from previous scene 4 Answers

scene loads properly when i load it manually but doesnt load properly when loading from other scene(using application,loadlevel ,also tried scenemanager). 3 Answers

UI cycling through my level select levels 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