• 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 TheTechZone · Oct 27, 2010 at 04:59 PM · guihidegui.boxclicked

How to Hide GUI Box Once Clicked?

Hi there. I'm working on an RPG game called 'Lost Worlds'. I've finally got the 3rd Person Player working in the game and now i'm working on the GUI. What i've done is that once you load up the game,a GUI Box displays, which has text introducing the player to the game. Please note that i have novice knowledge on scripting so please help me with this.

What i want to know is, what is the code for Javascript to hide the GUI Box once it is clicked so that the player, once read the message, can just click on it to cancel it out/ hide it?

Thanks! :)

Comment
Add comment
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

2 Replies

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

Answer by AliAzin · Oct 27, 2010 at 05:08 PM

you can do something like this:

var showBox = true; function OnGUI(){ if (GUILayout.Button("close this")) showBox = false;

if (showBox) GUILayout.Box("your Box");

}

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 TheTechZone · Oct 28, 2010 at 12:24 PM 0
Share

Thanks! Just what i needed! :)

avatar image
0

Answer by Steven Brewis · Nov 04, 2010 at 08:38 PM

is there a way to do exactly that, but on collision?

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 HolBol · Nov 04, 2010 at 10:59 PM 0
Share

get rid of the first 'if' statement in on gui, then add this above function OnCollisionEnter () { showBox = false; }

the gameobject needs a collider.

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

hide gui.label after an event 1 Answer

Changing GUI.Box opacity 3 Answers

Deleting GUI Box 2 Answers

How to use GUI.depth to bring a GUI.Box in front of other GUI elements? 1 Answer

how to toggle on/off a gameobject with a GUI button ? 3 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges