OnMouseOver GUI texture

hi guys, i’ve got a nice simple GUI texture here and i want it so when i mouse over it displays some info.

heres the script:

var PotIcon : Texture;

var T1 : Vector2 = Vector2 (200,120);
var T2 = 80;
var T3 = 80;
var T4 = 1;

function Update () {
}


function OnGUI () {
if(GlobalInsp.TakenPot) {
GUI.DrawTexture(Rect(Screen.width - T1.x, Screen.height - T1.y, T2,T3), PotIcon, ScaleMode.ScaleToFit, true, T4);
	}
}

function OnMouseOver () {
	print("hi");
}

Since GUI functions can only be called from OnGUI(), you’ll need to keep track of the mouse-over state. You could test for mouse-over directly, but to stick with the OnMouse*() events: you need to track when the mouse stops being over the object too, so you can turn the texture rendering off. This should do the trick (untested):

var PotIcon : Texture;

var T1 : Vector2 = Vector2 (200,120);
var T2 = 80;
var T3 = 80;
var T4 = 1;

function OnGUI () {
    if(GlobalInsp.TakenPot) {
        GUI.DrawTexture(Rect(Screen.width - T1.x, Screen.height - T1.y, T2,T3), PotIcon, ScaleMode.ScaleToFit, true, T4);
    }
}

function OnMouseEnter () {
	GlobalInsp.TakenPot = true;
}

function OnMouseExit () {
	GlobalInsp.TakenPot = true;
}

thanks, ill give it a try!

unfortunatly i cant get the above script to work. Would it be becuase firstly i dont have this script attached to the texture becuase the texture is called within the script, so i cant phsyically attach it so its a null reference? it would apply to what the script is attached to, In this case a empty game object. would have to find some way to refence the texture the mouse is hovering over in the script :\ but im not sure how to do this >.<