Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 JebKerman42 · Aug 13, 2015 at 05:08 AM · uibuttonscenemenureload

Button OnClick() Scripts lose assignments on scene reload

In my game I have a Menu scene with various buttons. In my game, when you die, it sends you back to the menu and you should be able to use the buttons to change the game settings (such as number of enemies). However, once it loads back into the menu scene after the game scene, none of the buttons do anything. Upon further inspection, I realized that the functions they had been assigned in the inspector had been cleared. How can I make it not do that?

Comment
Add comment · Show 5
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 NeverHopeless · Aug 13, 2015 at 06:44 AM 0
Share

We need to know how did you setup things up. Please post some relevant code. So we can investigate as well.

avatar image ZiB_Plays · Apr 05, 2017 at 01:04 PM 0
Share

Hi Jeb, Did you figure this out? I'm stuck on the same thing. @Jeb$$anonymous$$erman42

avatar image SohailBukhari · Apr 05, 2017 at 01:34 PM 0
Share

Show your code from which you are assigning buttons events. we don't know how you setup your events as @NeverHopeless said, we need to see your code.

avatar image ZiB_Plays SohailBukhari · Apr 05, 2017 at 04:03 PM 0
Share

Fixed

I've made "canvas$$anonymous$$anager" to carry buttons (HUD/options) across to the next scene. These buttons perform sound clicks, scene changes, mute audio etc. These functions have their own managers. I simply needed to carry them across too, so obvious. -.-

Using -

 public static Canvas$$anonymous$$anager instance = null;
 void Awake()
 {
     if (instance == null)
         instance = this;
     else if (instance != this)
         Destroy(gameObject);
     DontDestroyOnLoad(gameObject); ...

Problem now is the buttons show on all scenes. What's the best way to stop this? FYI, I'm very new to this.

avatar image SohailBukhari ZiB_Plays · Apr 06, 2017 at 06:48 AM 0
Share

$$anonymous$$ake your class non-singleton and make events in the class and then access needed functions from the canvas$$anonymous$$anager instance. Then assign your events from the non-singleton class.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by allenallenallen · Aug 13, 2015 at 05:08 AM

By coding it. Assign the buttons on load 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

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

Menu button in game isn't working 0 Answers

UI Button Focus 2 Answers

Button is not selectable when pressing the submit button even though it is highlighted. How do I fix that? 0 Answers

How To Put 2 Panel in 1 scene? 2 Answers

Use buttons to change string on other object 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