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
4
Question by daviddickball · May 29, 2015 at 09:21 AM · uitextpanel

What's the best way to hide/show a panel?

Simple question, but I'm struggling to find instruction on this. I have text in a panel (in a canvas), and I need to show it when dialogue is happening. What's the best way to show and then hide the panel?

I don't want to hide the entire canvas because I have other UI elements on screen (unless I should be using 2 separate canvas' for those?)

Comment
Add comment · Show 1
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 FWCorey · May 29, 2015 at 09:53 AM 0
Share

Yes you should be using separate CanvasGroups for each group of UI elements, then you can hide, show or animate each group with it's CanvasGroup container

4 Replies

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

Answer by FWCorey · May 29, 2015 at 10:00 AM

CanvasGroups are your answer though if you want to bind the group of UI elements to a different corner of the screen as a group they should also be on their own Canvas

Here is the info you need to manipulate the CanvasGroup through code if you like.

http://docs.unity3d.com/ScriptReference/CanvasGroup.html

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 daviddickball · May 29, 2015 at 10:36 AM 0
Share

Thanks, but how do you add a CanvasGroup? I can't seem to find it anywhere. $$anonymous$$aybe it's new to v5? I've still got 4.6, so just updating.

EDIT: Found it. It's a component under "Layout", I didn't think to look there.

avatar image
7

Answer by mafanbong8819 · Feb 25, 2017 at 05:12 PM

yes. it possible.

video - hide and show the panel

I think this tutorial can help you solve the problem.

This code is working for unity 5. Tested.

This code is to hide the panel.

     Panel.gameObject.SetActive (false);

This is to show the panel.

 Panel.gameObject.SetActive (true);

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 superfryme · Mar 12, 2018 at 07:32 PM 0
Share

this doesnt seem to work for me. the panel is not active but its still visible

avatar image smiller3650 · Oct 31, 2019 at 09:50 AM 1
Share

in start panel.setActive(false) then set it to true in desired function

avatar image
1

Answer by shoopscooper · Nov 12, 2019 at 12:59 AM

I know pretty late to the party, but I created an onclick event you can attach to any button object that will show or hide another object without making the object inactive (in case you have to manipulate it while it's inactive).

//to add to button object:

 yourButton.onClick.AddListener(() => showHidePanelDynamically(insertObjectToHideHere));

//method:

     public void showHidePanelDynamically(GameObject yourObject){
         var getCanvasGroup  = yourObject.GetComponent<CanvasGroup>();
         if (getCanvasGroup.alpha == 0){
             getCanvasGroup.alpha = 1;
             getCanvasGroup.interactable = true;
 
         }else{
             getCanvasGroup.alpha = 0;
             getCanvasGroup.interactable = false;
         }
             
     }

I hope this helps someone down the road!

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
0

Answer by Reedex · Oct 31, 2019 at 10:20 AM

Newer Post With Some More Info. Mainly The Video In The Thread. https://forum.unity.com/threads/canvas-off-on.753221/#post-5048900

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

29 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

Related Questions

How to get offset of a ScrollRect? 0 Answers

Figure out the pixel size of a character 1 Answer

Using iTween with the new Unity UI 2 Answers

Why wont my text box stay the same size? 2 Answers

[4.6 GUI] Displaying my pause menu when ESC is pressed 2 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