• 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
Question by Christian.Tucker · Nov 22, 2014 at 09:57 AM · ui

Unity 4.6 UI - Accessing a Panel from a Script?

Seems like the Panel is the only UI Component you can't access from a script, am I wrong? Am I missing it? Is it not called a Panel?

I need a simple way to manage a group of UI Components ( Similar to an online games interface popping up ), and have the ability to enable/disable them instantly.

Enabling/Disabling them one at a time is a mess, and grouping them is just so much easier.

Comment
Alex_Gol
anisabboud
Enyph-Games
M0no
BMRG14
depperm
alemuzzi17
BonusB
MiaJ17
ZachCleaver
RVDH

People who like this

11 Show 0
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

Answer by Kiwasi · Nov 22, 2014 at 10:06 AM

There is no such thing as a panel component. The panel created from the UI menu is a GameObject with a RectTransform and an Image component attached. You can access any of these via script. It sounds like what you are looking for is simply GameObject.SetActive()

Comment
anisabboud
crodriguez
illustir
Enyph-Games
M0no
BMRG14
botojomomo
Deniz2014
sampathcse16
alemuzzi17
ZachCleaver
RVDH
AllanHouse

People who like this

13 Show 3 · 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 Christian.Tucker · Nov 23, 2014 at 10:59 AM 0
Share

The problems I've always run into with SetActive() is that once you call it from a script, enabling that game object from the same script has become impossible, has it throws reference exceptions.

avatar image Kiwasi · Nov 23, 2014 at 06:41 PM 0
Share

It works fine if you keep a reference to the inactive object. The code that's causing you problems is one if the Find methods. As a rule these only return active objects.

avatar image illustir · Sep 01, 2015 at 10:37 AM 1
Share

Really, there is no actual Panel class!?

avatar image

Answer by BonusB · Jul 03, 2020 at 08:43 AM

I know I'm like 6 years late but, how do I reference a panel via script without using public variables? because prefabs can't use public variables.

Comment
Deshim

People who like this

1 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 Chris45215 · Aug 01, 2020 at 10:39 PM 0
Share

I'm not 100% sure what you're asking, so I'll answer a few variations of that question. If you want to have a reference to a prefab in a script, you can put a public GameObject there and drag-and-drop the prefab from the Asset menu into the slot in the inspector, just like you can drag-and-drop from the Hierarchy menu. Unity's guide for this is at https://docs.unity3d.com/Manual/InstantiatingPrefabs.html. For another variant of the question - scripts in prefabs can have public variables,

avatar image

Answer by coding_crow · Feb 16, 2015 at 09:29 AM

Look into Canvas Groups, I was wondering the same thing and they seem to do what we thought the panel was for.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

31 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

Related Questions

Unity 4.5 - Can't find UI in the “Create” list 2 Answers

A node in a childnode? 1 Answer

Unity 4.6 UI - A problem and a question 1 Answer

Z-index issues 2 Answers

How to perform a task in a specified time 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