Trying to get a script working for GUI where’s the GUI texture will change when I’ve hover’d over it etc, just wondering how’d I’d go about doing that?
Not to sure if I’d use OnGUI() or OnMouseEnter etc.
I’m using C#
Thanks if you can help!
Trying to get a script working for GUI where’s the GUI texture will change when I’ve hover’d over it etc, just wondering how’d I’d go about doing that?
Not to sure if I’d use OnGUI() or OnMouseEnter etc.
I’m using C#
Thanks if you can help!
Update;
This is what I’m using to test, I’ve got some other scripts setup etc, but thats irrelevant, what I want to know is how to change a texture to another texture when the mouse is over it.
This is what I tried, which gives no errors but doesn’t work.
public Texture2D hoverTexture;
public Texture2D NormalTexture;
public Texture2D PressTexture;
void OnMouseEnter()
{
NormalTexture = hoverTexture;
print("EnteredArea");
}
I dont know if this is useful (2014) but, if i reach this place looking for the same question, im sure that it is going to help another people, so here i go, this is the solution for HOVER and CLICK using UnityScript (Javascript). Hope i can help anyone
var normalTex : Texture2D;
var hoverTex : Texture2D;
function OnMouseEnter () {
guiTexture.texture = hoverTex;
}
function OnMouseExit(){
guiTexture.texture = normalTex;
}
function OnMouseDown(){
Debug.Log("clicked");
}