OnMouseOver Specific Objects C#

Hi

At the momenet I have a very basic test script, I want to know how I can make this work on differnt Specific objects using the same script.

using UnityEngine;
using System.Collections;

public class MouseOver : MonoBehaviour {

	public GameObject cube;

	void OnMouseOver(){        
		print (gameObject.name);     
	}
}

A non working example could be as follows.

using UnityEngine;
using System.Collections;

public class MouseOver : MonoBehaviour {

	public GameObject cube;

	//void OnMouseOvercube(){        
		//print (gameObject.name);     
	//}
}

Just add the script only on those specific objects. All the others won’t have this behaviour.

If you need the tags for something else, here is a solution with enums :

using UnityEngine;
using System.Collections;

public class MouseOver : MonoBehaviour 
{
     public enum MouseOverType{ Action1, Action2, Action3 /*, ...*/ }
     public MouseOverType mouseOverType;

     public GameObject cube;
 
     void OnMouseOver()
     {        
          switch(mouseOverType)
          {
               case MouseOverType.Action1 : /*Do stuff*/ break;
               case MouseOverType.Action2 : /*Do stuff*/ break;
               case MouseOverType.Action3 : /*Do stuff*/ break;
          }    
     }
}