How do I make that when I hover the mouse over GUI Texture it changes color?

Can someone please help me?
I’m using function OnMouseOver()
#pragma strict

function Start () {


function Update () {

function OnMouseEnter() {
renderer.material.color =;

However I am supposed to attach some renderer thing? Please help and also please don’t answer in the comments

Here’s a simple C# example which will start you going.

private Rect rect;
private Event EVENT;

private void Start(){
    rect = new Rect (0,0,100,100);

private void OnGUI(){
    EVENT = Event.current;

    if(rect.Contains(EVENT.mousePosition)) GUI.backgroundColor =;
    else GUI.backgroundColor =;

    GUI.Button (rect, "");
    //resets color to default
    GUI.backgroundColor = Color.white;

Theoretically, you can check does the rect contains mouse in update, but for that you
will have to use Input.mousePosition and fix y, as Input (0,0) starts from other corner. Like this

//This will return mouse position in GUI "normal" coordinate system
private Vector2 FixedInputMousePosition(){
    Vector2 pos = Input.mousePosition;
    pos.y = Screen.height - pos.y;

    return pos;

//And check it like this   
private void Update(){
        //Mouse is over rect

You may draw GUI Button instead of GUI Texture, and just customize “normal” and “hover” styles as you wish. it will change it’s view automatically.

And make you “active” style the same as “normal” style to make is looks not like button when user press it.

you can simply use the following and you can change mouse events as you wish;

GUITexture exampleGui;

        exampleGui.color =;

You might have to put a Box Collider on the GUI Texture.