Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 jwillis10 · Apr 01, 2018 at 11:57 PM · uigameobjectsetactiveparent-childpanel

GameObject.setActive(true) not working despite children and parents are active

As the title says, I cannot get a gameobject to become active. Its a UI panel object that is supposed to display after a fight and give a You win or You lose box to the player.

 public class OutcomeScript : MonoBehaviour {
 
     public GameObject outcomePanel;
 
     void Start () {
              outcomePanel.SetActive(false);
     }
     
     public void Outcome(int outcome) {
         if(outcome == 0)
         {
             outcomePanel.SetActive(true);
             outcomePanel.GetComponentInChildren<Text>().text = "You Win!";
             outcomePanel.GetComponentInChildren<Button>().GetComponentInChildren<Text>().text = "Continue...";
         }
         else
         {
             //"You lose" stuffs
         }
     }

I have confirmed that the function to set the object to active is being called correctly and passing the correct integer. I have also confirmed that the parent of the object (the UI canvas) is active and all of its children are active as well.

I'm not sure where to go from here, any help is appreciated.

Note: I'm in Unity 5.5.3 if that has any effect

Comment
Add comment · Show 4
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 FuryFight3r · Apr 02, 2018 at 03:31 AM 0
Share

The only thing that comes to $$anonymous$$d for me is that your Integer, outcome is not being set as 0? so the outcomePanel and its child references cannot be called?

Is there another script that sets this integer to become 0? If so, is that doing its job when it should be?

I may be wrong I'm not too familiar with ints and how they work exactly.

avatar image mgear · Apr 02, 2018 at 08:53 AM 0
Share

put some Debug.Log()'s there to see where the code goes.. maybe some other part of the code disables it after that?

Can you enable it manually from hierarcy, while its running?

avatar image FlaSh-G mgear · Apr 04, 2018 at 12:26 PM 0
Share

Yes, the checkbox is to the left of the object's name at the very top of the inspector.

avatar image YBtheS · Apr 05, 2018 at 09:21 PM 0
Share

Is the OutcomeScript attached to the outcomePanel GameObject? If so, the script will not run when it is inactive.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by davidcox70 · Apr 05, 2018 at 10:41 PM

It should work so look at some more fault-finding. For example, if you comment out the line outcomePanel.SetActive(false) in Start(), does the panel show? This might help narrow down if something else is also setting the panel inactive. Also view the hierarchy in the editor when you run your game. This will show if any parent is being made inactive which affects it's children.

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

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

Something in this Script keeps activating UI-Buttons 1 Answer

one button to hide and unihed gameobjects 0 Answers

Panel GameObject not activating 0 Answers

Panel GameObject not activating when called from another script 1 Answer

Translating GameObjects in AR onto a Panel? 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