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 Jan_Julius · Jun 16, 2015 at 10:18 AM · unity 5uigui

When loading into a new scene my UI doesn't work anymore?

I have DoNotDestroyOnLoad(this.gameObject); on my canvas and when I load into a new scene the buttons on my UI don't work anymore.

For example, the health still drains but the buttons and sliders don't work anymore?

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

3 Replies

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

Answer by Eudaimonium · Jun 16, 2015 at 12:47 PM

This is because the OnClick event bindings get reset. If you Pause the game and inspect the buttons, your OnClick events would probaby say something like, "Missing "

The way I have solved UI through multiple scenes is make an empty game object, put objects that have UI - related scripts in them in it, and put ALL UI stuff in it (Pause, Inventory and HUD screens and their cameras).

Then make a prefab out of the root GameObject, call it "LevelUIPackage" or something.

If all the OnClick (or other) events are bound to a script that is within the same prefab (within the same root object), they will get preserved. Otherwise if they're bound to a gameObject that's outside the prefab, they will get lost between scenes.

Another advice: Don't use DontDestroyOnLoad for UI, once you have your prefab UI package, just put it in every scene you need it in, and call it a day. That way you can select the scenes you want the UI in. It will save you the trouble if you quit the game to Main Menu for example.

Comment
Add comment · Show 6 · 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 Jan_Julius · Jun 16, 2015 at 01:39 PM 3
Share

I read the first sentence and realise I forgot to put an eventsystem with it :x

Thanks for the tips and your answer!

avatar image marksharkpark Jan_Julius · May 09, 2020 at 09:56 AM 0
Share

I had the same thing and I was so confused on what was happening. :)

avatar image BEFaughnan · Jul 13, 2015 at 02:25 PM 0
Share

hahaha wow, Yea, event system. Whoops.

avatar image Jan_Julius · Jul 13, 2015 at 03:00 PM 0
Share

One of those errors you make when you just been going for too long in one session!

avatar image buqal · Apr 27, 2016 at 11:33 AM 0
Share

Same happend to me .... eventsystem solved problem - thanks!!

avatar image NewYorkHOK · Apr 26, 2018 at 08:09 PM 0
Share

@Jan_Julius @BEFaughnan @buqal

How did adding the event system solve this? I have an event system and am still getting this problem. Any help would be appreciated!

Thanks

avatar image
0

Answer by Unplug · Aug 22, 2017 at 05:11 PM

make sure you are also destroying the object you put on the donotdestroy list when you reload your application or level. I had that problem signing out was trying you to a loginscreen but object were staying alive and on next login it was loaded twice on top of each other. I was also the victim of forgetting the event listener :O)

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 gOzaru84 · Jan 04, 2019 at 08:41 AM

In my case, I made UIManager and include all necessary Text for Score counting. When I declared its variable in GameManager and the game is resetting, the text doesn't display anything. I was wrong. I should declare its variable in UIManager, the first place its object attached to. Now my score text display in any level I want. But of course I need to copy canvas and its elements to all scenes. I don't make UIManager having Don'tDestroyOnLoad().

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

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

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

Related Questions

Problem with build version 1 Answer

Drawing UI text on GUI.DrawTexture , How to do it ? 1 Answer

Unity5 WheelCollider UI not showing???? 4 Answers

How to change a buttons color? 2 Answers

I created a HUD using new UI in Unity 5. I want to display that HUD in all 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