问题
最近在升级项目至2021版本的过程中发现了诸多这种问题,今天就遇到这样的报错:
Assets\Plugins\Demigiant\DOTween\Modules\DOTweenModulePhysics2D.cs(143,18): error CS1069: The type name ‘Rigidbody2D’ could not be found in the namespace ‘UnityEngine’. This type has been forwarded to assembly ‘UnityEngine.Physics2DModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ Enable the built in package ‘Physics 2D’ in the Package Manager window to fix this error.
Rigidbody2D(2D钢体)找不到的报错。
总结之前的问题,很快就能发现是Rigidbody2D(2D钢体)所在的包未引入的问题。
解决办法Window > Package Manager 打开窗口:
选择“Packages:Built-in”,找到”Physics 2D”包并选中它,点击右下角的“Enable”按钮:
等待”Physics 2D”启用完成,报错将会消失