Unity错误提示大全(遇到问题就更新)

记录下使用Unity中遇到的所有错误提示

1.Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.

  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)

   at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0

问题描述:

添加dllunity立马报错

问题根源:

dll的类库项目使用的是.NET 4.5 , unity 只支持.NET 2.0

解决方案:

修改dll的类库项目属性->应用程序->目标框架 为.NET 2.0

2.NullReferenceException: Object reference not set to an instance of an object

问题根源:

未将对象引用设置到对象的实例

定义了个TweenPosition变量tween,忘记赋值,后面直接调用tween.playforward方法

解决方案:

Awake里获取组件的引用,对变量tween进行赋值

tween = GetComponent<TweenPosition>();

原文地址:https://www.cnblogs.com/fzxiaoyi/p/8446158.html