On MouseOver not working

Hello there,

I spent past four hours trying to make this script work:

using UnityEngine;
using System.Collections;

public class subSceneSelected : MonoBehaviour {


	// Use this for initialization
	public float period = 2;
	public Color color = Color.red; 
	private Color originalColor; 

	private bool subsceneSelected = false;
	


	/* Blinking started */
void Start () {
	  subsceneSelected = false;
     originalColor = gameObject.renderer.material.color;
		StartCoroutine(CheckEnable());
  }
	 
  public IEnumerator CheckEnable() {
     while (true){ 
       if (!subsceneSelected) {//if subscene is not selected 
	   yield return StartCoroutine(ChangeColor()); // Note that "enable" will not be detected until we returned from ChangeColor(). How to fix this problem?
       }
       //print("CheckEnable @"+System.DateTime.Now.ToString("hh:mm:ss:ff"));
       yield return 0;
      }
   }
	
   public IEnumerator ChangeColor() {
    Material[] stuff= gameObject.renderer.materials;
	
	   for (int i=0; i < gameObject.renderer.materials.Length; i++){
	   
	if (stuff[i].color == originalColor) {
  	   stuff[i].color = color;


	}else {
	   stuff[i].color = originalColor;

	}  
	}
 	//print("Color changed @ "+System.DateTime.Now.ToString("hh:mm:ss"));
	yield return new WaitForSeconds(period);
   }
	
   void Update(){
	   
	   
	}

	void onMouseDown () {
		
	if (subsceneSelected == false)
	 subsceneSelected = true;
//It then does something
}
}

When attached to an object, object blinks, and when this object is being selected with the mouse,on Mouse Down function, it then stops blinking and it then does something. But it’s never called. I’ve attached this script to some objects that have another scripts with MouseDown functions and they are working fine, but this isn’t. I even tried to comment code with blinking and it0s not working…or I’m just getting tired of Unity. Nothing makes sense…Do you have suggestion?

can you post code that calls onMouseDown ?

Try changing onMouseDown to OnMouseDown - I’m pretty sure it’s case sensitive.

OK, here is it. It seems bit complex - I even tried to remove all those line and put just these

if (subsceneSelected == false)
	 subsceneSelected = true;
	gameObject.renderer.material.color = color;

instead of

void onMouseDown () {
		
	if(subsceneSelected == false){
	 subsceneSelected = true;	
	 script = GameObject.FindWithTag("FPS").GetComponent<CameraController>();
	//Tell FPS that sub-scene is selected and turn off cameraTopView
	 script.subSceneSelected();
	 disableTopCamera();
                  //TO DO: fade IN and Out.....
		
	 //TO DO: draw GUI

	initiateSubScene();
	 }
	
	}
	
	void disableTopCamera(){
		
		GameObject.Find("Top Camera").GetComponent("Camera").active = false;

		
	}
	
	void enableTopCamera(){
		
		GameObject.Find("Top Camera").GetComponent("Camera").active = true;
		
		
	}
	
	void initiateSubScene(){
		
					//open the doors
	GameObject.Find("vrata1").animation.Play("vrata1Open");
	GameObject.Find("vrata2").animation.Play("vrata2Open");
			
		
}

But either way, it’s not working…

Oh, damn…it is OnMouseDown instead of onMouseDown…OK, I will call this failure as one great experience. Thank you very much!