OnMouseEnter not working?

Hi all,

Im having a problem making onMouseOver work. I am using a very simple code to test whether it is working.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class slotObjectsClass : MonoBehaviour {

	static public bool hasPegAttached;
	public GameObject slotObject;
	static public bool isHighlighted;
	static public Vector3 slotPosition;
	static public GameObject pegObject;
	static public float xDiff;
	static public float zDiff;
	static public bool overSlot;
	
	// Use this for initialization
	void Start () {
		slotPosition = slotObject.transform.position;
	}
	
	// Update is called once per frame
	void Update () {
		pegObject = pegClass.pegsByColour[pegClass.pegsByColour.Length - 1];
		xDiff = pegObject.transform.position.x - slotObject.transform.position.x;
		zDiff = pegObject.transform.position.y - slotObject.transform.position.y;
		Debug.Log(overSlot);
	}
	
	void OnMouseEnter () {
		overSlot = true;
	}
	
	void OnMouseExit () {
		overSlot = false;
	}
	//if xDiff < 0.12 and more than -0.12
	//if zDiff < 0.12 and more than -0.12
}

so i'm expecting "true" to show at some point, however it does not. Bear in mind I have this script attached to 54 slots!! 

The slots also all have box colliders on, which are not triggers and have not material set.

Any ideas?

Does the object have a collider?

Sorry I did write that but I managed to put it into the code section! :smile:

Debug.Log takes in a string as a parameter. overSlot is a boolean value.

static function Log (message : Object) : void This is taken from the docs. Debug.Log takes in an object value not string. Therefore it’s fine to pass a boolean value in. Maybe I think the object might be in a wrong layer say ignore raycast or you might not have attached the script properly. Otherwise i think you can try setting overSlot as a public bool instead of a static public bool