
unity
ciumm
这个作者很懒,什么都没留下…
展开
-
使用摄像机中心发出射线检测
射线方法 Ray ray; LineRenderer lineRenderer; // Update is called once per frame void Awake() { lineRenderer = gameObject.AddComponent<LineRenderer>(); lineRenderer.SetWidth(0.1f, 0.1f); } void LateUpdate()原创 2020-09-18 05:13:16 · 617 阅读 · 0 评论 -
StartCoroutine NullReferenceException协程未实例化
StartCoroutine NullReferenceException 最近在一个工具类做了一个协程http请求,一直报nre,打断点看了工具类用到的类都实例化了,后来查阅了一下,发现这个。 通俗的讲就是协程是MonoBehaviour的实例成员,而继承与MonoBehaviour的类是不能实例化的,需要挂在物体上,unity自动实现生命周期。所以AddComponent来加载组件也可以把这个类挂载在空物体上然后通过GetComponent来获取对象。(不得不说自己记忆力真的好差最基本的都忘了) ..原创 2020-06-06 17:03:41 · 950 阅读 · 0 评论 -
unity鼠标控制人物的rotation
鼠标控制人物的rotation 不是最优解,不知道怎么直接操作z轴。 using System.Collections; using System.Collections.Generic; using UnityEngine; public class move : MonoBehaviour { public GameObject target; float x, y; ...原创 2019-12-03 21:22:13 · 191 阅读 · 0 评论