Unity 报错之 The type or namespace name 'UI' does not exist in the namespace Unity

493 阅读1分钟

小知识,大挑战!本文正在参与“程序员必备小知识”创作活动。

产生报错:

之前使用Unity2017版本开发的工程,误用Unity2019版本打开了,报错如下:

The type or namespace name 'UI' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

类型或命名空间名称'UI'不存在命名空间'UnityEngine'(你缺少一个程序集引用?)

1.1

解决问题:

在工程中导入UI程序集步骤如下: “Window” -- "Package Manager" -- "Unity UI" --> "Install" 1.2

导入成功后,解决已错误。


其他问题:

The type name 'MeshCollider' could not be found in the namespace 'UnityEngine'. This type has been forwarded to assembly 'UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' Enable the built in package 'Physics' in the Package Manager window to fix this error.

根据上文提示:需要导入 UnityEngine.PhysicsModule ,方式如下: 同样类似的问题的话,都根据提示进行导入相关的模块就可以了。

1.3