一、射线检测
1、Physics
1)Static Functions
a、Raycast 发射一条射线,判断有没有和别的碰撞体发生碰撞
b、Physics.Raycast(ray,maxDistants);
Physics.Raycast(ray,RaycastHit);
Physics.Raycast(Vector3 origin,Vector3 direction);
Physics.Raycast(ray,distants,LayerMask(“Layer”));//"Layer"指射线只与它这一层碰撞
c、2D射线检测和检测碰撞到所有物体
Physicals2D.Raycast();
d、Physics.RaycastAll() 可以检测碰撞到的所有物体,Raycast只能检测碰撞到的第一个物体。
二、UGUI 事件监听
1、拖拽
2、代码添加
using System.Collections;
using System.Collectio