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

Ui button

Discussion in 'Getting Started' started by PRABHBIR123, May 23, 2017.

  1. PRABHBIR123

    PRABHBIR123

    Joined:
    Apr 9, 2017
    Posts:
    72
    I have created a button and named it left. I used a script on it which is
    void OnMouseDown ()
    {
    Debug.Log ("hello");
    }
    Now when i press my button my console window don't show anything. I have used box collider on it please help
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
  3. PRABHBIR123

    PRABHBIR123

    Joined:
    Apr 9, 2017
    Posts:
    72
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,141
    Right. Unity's UI uses a different method to receive user input. Watch the video he linked. It'll show you how.
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    OnMouseDown isn't the way to do this. Instead you want to create a public method, then add it as a listener via the inspector.
     
  6. PRABHBIR123

    PRABHBIR123

    Joined:
    Apr 9, 2017
    Posts:
    72
    Thank you for helping