unity mouse button code example
Example 1: unity get mouse position
Vector3 worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Example 2: unity left mouse button
Input.GetKey(KeyCode.Mouse0))
Example 3: left moust click unity
if(Input.GetMouseButtonDown(0))
if(Input.GetMouseButtonDown(1))
if(Input.GetMouseButtonDown(2))
Example 4: onmouseclick unity
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;public class ExampleClass : MonoBehaviour
{
void OnMouseDown()
{
Destroy(gameObject);
}
}