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
0
Question by Meethani · Sep 04, 2017 at 11:37 AM · how to

Main Menu Buttons SetAtive(true) not working

I have made a Main Menu Scene where at Start Buttons and Text are invisible. After a short time these activated and that works fine when I start game. However, when my game finished and I go back to Main Menu these Buttons and Texts remain invisible. My Main Menu Script is as under:-

alt text

I need help in this regards as I am Beginner in Coding

main.png (46.5 kB)
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 Imankit · Sep 04, 2017 at 12:17 PM 0
Share

Can you post full script and editor screenshots showing what exactly you are doing?

avatar image Meethani Imankit · Sep 04, 2017 at 12:44 PM 0
Share

I just want to set visibility of buttons after 1 second on $$anonymous$$ain $$anonymous$$enu and it works perfect when I start game but when game finished and I go to $$anonymous$$ain $$anonymous$$enu by pressing Game Over $$anonymous$$enu; buttons of $$anonymous$$ain menu does not activate.

The script showed above is a part that used for this purpose.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by akillingbeck · Sep 04, 2017 at 12:53 PM

Use unity functions OnEnable, OnDisable

https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnEnable.html

https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDisable.html

OnEnable gets called when the script becomes enabled (gameobject gets turned back on) OnDisable gets called when the script becomes disabled(gameobject gets turned off)

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 Meethani · Sep 04, 2017 at 05:42 PM 0
Share

How can I implement OnEnable and OnDisable to make object visible/invisible? I will be thankful if you can guide me for this Function.

avatar image akillingbeck Meethani · Sep 05, 2017 at 08:22 AM 0
Share

1) Remove Start and Awake functions 2) Add these functions:

 private void OnEnable()
 {
  StartCoroutine(Frame(0.5f,true));
 }
 private void OnDisable()
 {
  StartCoroutine(Frame(0.0f,false));
 }
 
 public IEnumerator Frame(float waitFor,bool setActive)
 {
   yield return new WaitForSeconds(waitFor);
   t2.SetActive(setActive);
   yield return new WaitForSeconds(waitFor);
   t1.SetActive(setActive);
   yield return new WaitForSeconds(waitFor);
   frame.SetActive(setActive);
   b1.SetActive(setActive);
   b2.SetActive(setActive);
   b3.SetActive(setActive);
   b4.SetActive(setActive);
   
 }

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

69 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 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 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

how do you make a 3d person or object? 2 Answers

SQLite in Unity 4.x? 0 Answers

how to open probuilder basic 1 Answer

How do i make my player jump from an angle? (Wallrun Jump) 1 Answer

How to make atmospheric dust particles? 4 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