Unity 4.6 UI Button to change Game Object Material.

First of let me apologize for my poor English. I’ll try my best to explain my problem.

I have a set of GUI Buttons made with the new UI system in Unity 4.6. I’d like for certain objects in my scene to change color when I mouse over these buttons, in this case arrows showing different parts of my 3D model.

Right now I’m using this:

using UnityEngine;
using System.Collections;

public class ChangeArrowColor : MonoBehaviour {

	private Color startcolor;
	public GameObject Arrow;

	public void OnMouseEnter() {

		startcolor = Arrow.renderer.material.color;
		Arrow.renderer.material.color = Color.gray;
		
	}
	
	public void OnMouseExit() {

		Arrow.renderer.material.color = startcolor;
		
	}
}

This works great if placed on the game object itself or any other object in the scene. But it does not work if placed on the button, or used with an empty and the On click management provided in the new UI system, seeing as how it wants me to actually click for stuff to happen.

Now I might be way off but my first thought was that the button is missing necessary colliders, so I tried adding a boxcollider to it, both a normal one and a 2D one, none of which helped.

Any help is appreciated. Thanks.

Best Regards.

You need to use the interfaces for the event:

using UnityEngine.EventSystems;
public class ChangeArrowColor : MonoBehaviour, IPointerEnterHandler 
{	
    public void OnPointerEnter(PointerEventData eventData)
    {
        print("Hi");
    }
}