Posts

Showing posts with the label mouseclick

"on click" basics

From the Unity pages, a simple way to detect your mouse clicks - using UnityEngine; using System.Collections; // Detects clicks from the mouse and prints a message // depending on the click detected. public class ExampleClass : MonoBehaviour { void Update () { if ( Input.GetMouseButtonDown (0)) Debug.Log ("Pressed primary button."); if ( Input.GetMouseButtonDown (1)) Debug.Log ("Pressed secondary button."); if ( Input.GetMouseButtonDown (2)) Debug.Log ("Pressed middle click."); } }    And from this site - void Update ( ) { if ( Input . GetMouseButtonDown ( 0 ) )        {      Ray ray = Camera . main . ScreenPointToRay ( Input . mousePosition ) ;      RaycastHit hit ;      if ( Physics . Raycast ( ray , out hit ) )             {           Destroy ( h...