|
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.??
(comments are locked)
|
|
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. Cheers dude, such a simple answer in the end, i though this question had been long forgotten
May 05 '11 at 10:15 AM
cormac
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 }
May 05 '11 at 10:59 AM
cormac
(comments are locked)
|
|
Simple way: Make a empty object with only GUIs, transform in a prefab, destroy to "hide" and instantiate to "show". 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.
Jan 13 '11 at 12:48 PM
cormac
(comments are locked)
|
|
This is the code i used in the end function Update(){
if (showGUI == true) {
(comments are locked)
|
