I have a script attached to a prefab that gets instantiated into the scene. When the prefab is moused over, it should display a gui. But it doesn’t.
The only possibility I can think of was that you can only have one OnGui function being called at one time, as I have a different script displaying several gui elements constantly. However this link negates that:
Unity Answers: Can You Make OnGUI Calls From Multiple Gameobjects
I also verified that the monobehavior checkbox is enabled in the inspector on the gameobject this script is attached to per:
MonoBehaviour.OnGUI() Script Reference
the Debug.Log(isHover); prints 1 in the console, so OnMouseOver() is working as it should.
Please help! This is my code:
function OnGui(){
if (isHover==1){
GUI.Box (Rect (0,0,Screen.width,Screen.height),"");
}
}
function OnMouseOver(){
isHover= 1;
Debug.Log(isHover);
}
function OnMouseExit(){
isHover= 0;
}