Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity know when gameobject presed

void Update () {
         if (Input.GetMouseButtonDown(0)) {
             CastRay();
         }       
     }

     void CastRay() {
         Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit2D hit = Physics2D.Raycast (ray.origin, ray.direction, Mathf.Infinity);
         if (hit.collider !=null) {
             Debug.Log (hit.collider.gameObject.name);
     }
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# string to datetime 
Csharp :: ienumerator 
Csharp :: c# map number range 
Csharp :: unity how to load up a scene 
Csharp :: require admin privileges c# 
Csharp :: unity time.deltatime timescale 0 
Csharp :: how to chnage the Scale propery of rect tranform unity 
Csharp :: c# boiler code shortcut 
Csharp :: backcolor c# hexadecimal 
Csharp :: c# change cursor 
Csharp :: loadscene unity 
Csharp :: c# add item to a lsit 
Csharp :: how to make a pause feautre in unity 
Csharp :: stock span problem c# 
Csharp :: wpf load file content 
Csharp :: c# random choice 
Csharp :: how to log out of unity asset store 
Csharp :: remove last character from string c# 
Csharp :: how to draw over label C# 
Csharp :: how to get element dictionary key in c# by index 
Csharp :: c# open file 
Csharp :: no move arrows unity 
Csharp :: C++ in C# 
Csharp :: unity set text value 
Csharp :: console writeline unity c# 
Csharp :: monodevelop ubuntu 20.04 
Csharp :: c# tryparse int 
Csharp :: dictionary to string c# 
Csharp :: Unity banner ad C# 
Csharp :: best way to compare byte array c# 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =