![](https://img-blog.csdnimg.cn/20201205204605995.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
Unity
自学Unity遇到的一些知识点和坑
Junkman996
主要用于个人学习和记录。
展开
-
Unity 访问其他脚本中的属性或方法——Unity单例模式
在一个脚本中访问另一个脚本中的属性或方法例如你想要在脚本A.cs中访问B.cs的变量或者方法// A.cspublic class A: MonoBehaviour { public static A instance; // static关键字。 单例模式 //使用Awake()确保单例模式在使用前已被初始化 void Awake(){ instance = this; } //属性或者方法需要时public的 public int name; public vo原创 2020-12-07 21:40:17 · 2375 阅读 · 0 评论 -
Unity中Destory()、DestoryImmediate()和GameObject==null问题
public class TestH_Destory : MonoBehaviour{ public GameObject test1; public GameObject test2; private void Start() { Destroy(test1); DestroyImmediate(test2); Debug.Log(test1 == null); Debug.Log(test2 == nul原创 2020-12-07 19:11:35 · 475 阅读 · 0 评论