命名空间

时间:2016-03-04 17:42:38

标签: c# unity3d reference namespaces

所以我一直在研究Unity项目一段时间以来,几周前我每次尝试将visual studio连接到Unity时都会遇到多个错误。我得到的所有错误都与'UnityEngine.UI'有关。

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

我根本没有编辑过解决方案文件,我也没有更改任何引用。

现在奇怪的是,当我构建获取错误列表时,但是如果我双击一个它将我带到错误位置然后所有错误消失,就像解决方案没问题。但是,如果我构建项目,我会收到所有错误......

我认为你可以重现这个错误的唯一方法是制作一个新的Unity项目(我正在使用5.3.3f1),创建一个脚本并包含这个命名空间

using UnityEngine.UI;

然后看看你是否可以构建项目。如果有人知道这个项目的解决方案会很棒:)

同样在我的“警告”窗口中,我有这3个

The primary reference "UnityEditor" could not be resolved because it has an indirect dependency on the framework assembly "System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5,Profile=Unity Web v3.5".

The primary reference "UnityEngine.Networking" could not be resolved because it has an indirect dependency on the framework assembly "System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5,Profile=Unity Web v3.5".

The primary reference "UnityEngine.UI" could not be resolved because it has an indirect dependency on the framework assembly "System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5,Profile=Unity Web v3.5".

1 个答案:

答案 0 :(得分:1)

当您的上一个构建目标是" Web Player"。

时,会发生这种情况
  1. 打开:文件 - >构建设置...
  2. 选择PC,Mac& Linux Standalone
  3. 构建游戏 - 在此步骤中,将修复VS解决方案设置