Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

onMouseDown() not detecting the click

Discussion in 'Scripting' started by FalconJ, Mar 19, 2015.

  1. FalconJ

    FalconJ

    Joined:
    Mar 12, 2015
    Posts:
    146
    I have two object with colliders attached to them. Also I have attached this basic script to test if the click is detected or not :
    Code (CSharp):
    1.         void onMouseDown(){
    2.         Debug.Log ("clicked");
    3.     }
    But the debug is not called so the click is not detected.

    What's wrong?
     
  2. Mr-Mud

    Mr-Mud

    Joined:
    Mar 8, 2015
    Posts:
    37
    All of Unity's magical functions start with a capital letter. Since your function doesn't, it won't be invoked by Unity. Changing it to "OnMouseDown" should solve the issue.
     
    theANMATOR2b, FalconJ and MagicZelda like this.
  3. FalconJ

    FalconJ

    Joined:
    Mar 12, 2015
    Posts:
    146
    oh well, that fixed the issue. thank you mr. mud