![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
unity常用API
一些unity中十分常用的API个人总结
Asce66
喜欢Unity,想进入游戏开发行业
展开
-
Input_键盘键盘与手机触摸屏
手机触摸屏Input.touchCount //手指数目Touch touch=Input.touches[0];//获得对应手指Touch touch = Input.GetTouch(0);//获得对应手指 touch.fingerId //手指按下时创建一个Touch对象,并分配一个fingerIDinfo += "deltaPosition" + touch.deltaPos...原创 2020-03-11 21:28:40 · 839 阅读 · 0 评论 -
UI事件处理接口
拖动接口public class TestDrag : MonoBehaviour,IInitializePotentialDragHandler,IBeginDragHandler,IDragHandler,IDropHandler,IEndDragHandler//开始之前(鼠标点击时) //开始拖动 拖动中 拖动放下 结束拖动(执行顺序也是如此)其他四个接口都必须现在实现...原创 2020-03-11 10:58:48 · 194 阅读 · 0 评论 -
查找游戏物体以及发送消息
查找游戏物体:GameObject go=GameObject.FindWithTag("palyer");//找一个GameObject []go=]GameObject.FindGameObjectWithTag("palyer");//找全部GameObject gg=GameObject.Find("Cube");//按名字查找(效率不高,慎用)查找物体组件:Ri...原创 2020-03-11 10:53:59 · 78 阅读 · 0 评论 -
Transform Rigidbody Time
Transform类:transform.position;transform.Translate//物体相对位移的单位transform.Roate;transform.eulerAngles;//物体的角度transform.localScale;//物体的缩放Rigidbody类:刚体也能控制position与rotation且改变更快,colider不需要重新计算,优先考...原创 2020-03-11 10:48:32 · 133 阅读 · 0 评论 -
四元数(Quaternion)
Unity中物体的旋转(Rotation)是由四元数控制的四元数的乘法运算就是旋转的叠加this.transform.rotation*=Quaternion.Euler(0, 1, 0);*号而不是+号 //可使物体沿自身坐标Y轴旋转四元数右乘一个向量表示把向量旋转对应的角度Vector3 pos = Quaternion.Euler(0, 30, 0) * new Vect...原创 2020-03-11 10:40:45 · 627 阅读 · 0 评论 -
Random类与Mathf类
Random类:Random.InitState(1);//随机数种子Random.State rs= Random.state;//得到种子并保存Random.Range(0, 1);//也可以是小数,参数中有一个为小数即可Random.insideUnitCircle;//在一个中心在原点,半径为1的圆内随机生成一个坐标Random.insideUnitSphere;//球内...原创 2020-03-11 10:35:11 · 251 阅读 · 0 评论