Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Getting Mouse Click Event form a 3d GameObject in Unity

    • 0
    • 17
    • 517
    • 1
    • 0
    • 0
    • 0
    • 0
    • 2.64k
    Comment on it

     We get a click event when we click a Button in UI , but how to get a click event while clicking on  a GameObject from our scene .

     It is very simple .

     To get a click event from a object , add a collider to that object and then add a  script to it with a simple Code :

    using UnityEngine;
    using System.Collections;
    
    public class GetClick: MonoBehaviour
    {
        void OnMouseDown()
        {
           Debug.Log("GameObject Clicked");
        }
    
    }

    This script will give a click event from that GameObject .

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: