Hello,
I have a script that requires the player to hover the mouse over an object and hold a key down (z). I set it up so the GUI displays some information OnMouseEnter, and clears that information OnMouseExit. However, it seems that holding down z rapidly activates and deactivates the mouse cursor, so that it switches between Enter and Exit, causing the GUI to flicker. Does anyone know how to make held down keys leave the mouse alone?
Thanks for taking a look at this.
EDIT: Here's an update with some script: Here's what's on the object to display and clear the GUI data:
function OnMouseExit () {
guidata.tipname = null;
guidata.tiphits = 0;
guidata.tiphead = null;
guidata.tiptorso = null;
guidata.tiplegs = null;
}
<p>function OnMouseOver () {</p>
var unitdata = gameObject.GetComponent(state);
guidata.tipname = unitdata.unitid;
guidata.tiphits = unitdata.hits;
guidata.tiphead = unitdata.head;
guidata.tiptorso = unitdata.torso;
guidata.tiplegs = unitdata.legs;
}
Hmm, the thing killed my formatting, but I think you can tell what's going on.
And here's the keypress:
function Update () {
if (Input.GetButton("z")){
gameObject.renderer.enabled = true;
}
if (!Input.GetButton("z")) {
gameObject.renderer.enabled = false;
}
}