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
0
Question by TechnoRazor · Dec 27, 2014 at 08:03 PM · guistorehidecommandshop

How do I hide GUI?

I built a simple store with a trigger to detect when I go up to the counter. I also have this code on a panel GUI. I want the panel to be hidden at first, but I also want the trigger to show the panel when I go into it. I made sure the trigger works, it changes the variable Shopping to true, but I can't hide the GUI. I am probably using the wrong command. Can someone please tell me the right one?

 #pragma strict
 
 static var Shopping = false;
 
 function Start () {
 
 }
 
 function Update () {
     GUI.enabled = Shopping;
 }
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 Mmmpies · Dec 27, 2014 at 09:37 PM 0
Share

is this 4.6 GUI or OnGUI?

avatar image TechnoRazor · Dec 27, 2014 at 09:42 PM 0
Share

This is the panel in GameObject/UI/Panel On the top. I'm not very good at GUI, so I don't know exactly what you mean.

avatar image Mmmpies · Dec 27, 2014 at 09:50 PM 0
Share

Are you using Unity 4.6 or 5, if using the new GUI then you'll be using a canvas.

I think you're probably using the old OnGUI that I'm not familiar with but if you are using the new 4.6 and newer GUI then I can help.

avatar image TechnoRazor · Dec 28, 2014 at 02:30 AM 0
Share

I was using the Canvas with 4.6. Sorry I replied late. I already got an answer from 'getyour411', but thanks anyway.

3 Replies

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

Answer by getyour411 · Dec 27, 2014 at 09:49 PM

Setup a variable, drag/drop panel reference in Editor

 public Gameobject myPanel;

In Awake/Start/whatever set it to false

 myPanel.SetActive(false);

In your trigger set it to true

 myPanel.SetActive(true);

(and then false again on Trigger false condition)

Don't know JS

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 TechnoRazor · Dec 27, 2014 at 10:12 PM 0
Share

Thank you so much! It took me a while, put I was able to "translate" it to Javascript.

avatar image
0

Answer by rezki · Dec 27, 2014 at 08:08 PM

before the line that does all the GUI.simply add

 if(Shopping)
 {
     // Your GUI lines
 }
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 TechnoRazor · Dec 27, 2014 at 09:21 PM 0
Share

I tried that too, it didn't work.

avatar image
0

Answer by JA_555 · Dec 28, 2014 at 03:52 AM

if you don't need any other GUI on the screen, you could just go to your camera and have a script uncheck the GUILayer. When you need the GUI gone just simply have:

 GameObject.Find("Main Camera").GetComponent(Camera).GUILayer = false;
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 Kiwasi · Dec 28, 2014 at 08:07 AM 0
Share

The layer solution appears to be faster then set active, even with multiple canvases. Simply move the canvas to a later that is not rendered.

avatar image TechnoRazor · Dec 28, 2014 at 01:20 PM 0
Share

I have more GUI on the screen, so that wouldn't work, but you gave me an easier to do it in the future if I need to.

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

Unibill in-app purchase plugin, any experience? 3 Answers

I have a skin store where l want to put my animted charcter 0 Answers

StoreGUI problems 1 Answer

Hide GUI label on press 1 Answer

How to Hide the GUI when time.scale = 1 again 1 Answer


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