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 cormac · Jan 13, 2011 at 11:56 AM · guiscreenrecordingonmouseover

Make GUI elements disappear

HI. I have a few GUI elements (two slider bars and a few buttons) onscreen which help me adjust the speed and position of a fly through camera, i am then recording the fly throughs with screen capture software. The problem is i would like the GUI elements to be invisible unless the mouse is over the screen. Can anybody help.??

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

3 Replies

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

Answer by Ashkan_gc · Apr 30, 2011 at 05:01 AM

well! check the position of the mouse and depending it's position set a variable (say showGUI) to true and false and then in your OnGUI check the variable to see if you should draw the gui or not in this frame.

void OnGUI ()
{
if (showGUI == true) { //show your gui and call them }
else {//don't do anything related to those GUI elements }
}
void Update ()
{
if (Input.mousePosition.y > Screen.height/2 ) //check any other condition that is suitable for you
{
showGUI = true;
}
else
showGUI = 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 cormac · May 05, 2011 at 10:15 AM 0
Share

Cheers dude, such a simple answer in the end, i though this question had been long forgotten

avatar image cormac · May 05, 2011 at 10:59 AM 0
Share

This is the final codde

function Update(){ if (Input.mousePosition.y < Screen.height && Input.mousePosition.y > 0 && Input.mousePosition.x < Screen.width && Input.mousePosition.x > 0) //check to see if the mouse is over the Screen { showGUI = true; } else { showGUI = false; }

function OnGUI(){ if (showGUI == true) { //gui stuff }

avatar image
0

Answer by Borgo · Jan 13, 2011 at 12:17 PM

Simple way:

Make a empty object with only GUIs, transform in a prefab, destroy to "hide" and instantiate to "show".

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 cormac · Jan 13, 2011 at 12:48 PM 0
Share

I see what you mean, but i think to do this would mean hugh changes to my script, as the gui scripts are part of a much more complex script on the main camera which places it on a path defined by points in the scene and moves it along this path using iTween. all this script is on the main camera.

avatar image
0

Answer by cormac · May 05, 2011 at 11:03 AM

This is the code i used in the end

function Update(){

if (Input.mousePosition.y < Screen.height && Input.mousePosition.y > 0 && Input.mousePosition.x < Screen.width && Input.mousePosition.x > 0) //check to see if the mouse is over the Screen
{
showGUI = true;
}
else
{
showGUI = false;
}
function OnGUI(){

if (showGUI == true) {

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

No one has followed this question yet.

Related Questions

How Do I Center A GUI Label? 5 Answers

OnMouseOver Tower Gui Health Bar 2 Answers

how to get Gui in OnGUI function to resize with the window? 1 Answer

Make a document pop up on screen 1 Answer

Displaying score on screen in specific place 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