简体   繁体   English

编译此程序集时为什么会出现以下错误?

[英]Why am I getting the following error when compiling this assembly?

I'm attempting to use the following command line command to compile an assembly of the code from my project: 我正在尝试使用以下命令行命令来编译我的项目中的代码程序集:

C:/"Program Files"/Unity/Editor/Data/Mono/bin/gmcs 
-target:library -out:C:/Users/Austin/Desktop/PixelExpanse.dll 
-recurse:C:/Users/Austin/Desktop/Projects/Repos/trunk/PixelExpanse/SpaceColonyRefactor/Assets/Source/*.cs 
-d:RUNTIME -r:C:/"Program Files"/Unity/Editor/Data/Managed/UnityEngine.dll

As you can see, I am, I believe, correctly referencing the UnityEngine.dll . 正如您所看到的,我相信,我正确地引用了UnityEngine.dll The code that would be compiled contains references to UnityEngine.UI and UnityEngine.EventSystems . 要编译的代码包含对UnityEngine.UIUnityEngine.EventSystems引用。 But when I run the above command, I get the following compile error: 但是当我运行上面的命令时,我得到以下编译错误:

error CS0234: The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine'. 错误CS0234:名称空间“UnityEngine”中不存在类型或命名空间名称“EventSystems”。 Are you missing an assembly reference? 你错过了装配参考吗?

From what I have been able to find through googling, it SEEMS like an error people were getting when using a pre-4.6 assembly, because thats when EventSystems and UI were both introduced. 从我通过谷歌搜索找到的东西,它看起来就像人们在使用4.6之前的程序集时所遇到的错误,因为那时引入了EventSystems和UI。 But I don't know how I could be missing that in the dll I'm referencing as Unity 5 is the only version that has ever touched this computer. 但是我不知道在我引用的dll中我是如何错过的,因为Unity 5是唯一曾触及过这台计算机的版本。

As a side note, I have posted this question to Unity Answers and have yet to receive a response. 作为附注,我已将此问题发布到Unity Answers并且尚未收到回复。 I expect it's because assembly compilation is beyond the scope of what most users there choose to undertake. 我希望这是因为汇编编译超出了大多数用户选择的范围。 Hence my asking it here. 因此,我在这里问。

The namespace UnityEngine.EventSystems actually appears in UnityEngine.UI.dll and not UnityEngine.dll so it seems you need to reference the former too when compiling manually from the command-line. 命名空间UnityEngine.EventSystems实际上出现在UnityEngine.UI.dll而不是UnityEngine.dll中,因此当从命令行手动编译时,您似乎也需要引用前者。 Unity projects have this by default (see below). Unity项目默认具有此功能(见下文)。

This is verified by opening up the assembly in your reflector tool of choice, here I am using JetBrains dotPeek : 这是通过在您选择的反射器工具中打开组件来验证的,这里我使用的是JetBrains dotPeek

在此输入图像描述

This is how my test project appears with default Unity references. 这是我的测试项目与默认Unity引用一起出现的方式。 Note that by default a reference to UnityEngine.UI already appears in the Unity-created project: 请注意,默认情况下, UnityEngine.UI的引用已经出现在Unity创建的项目中:

在此输入图像描述

When I built my Windnows desktop app via Unity, the above dlls appeared in: 当我通过Unity构建我的Windnows桌面应用程序时,上面的dll出现在:

< drive >:< projectOutFolder >\\< projectName > _Data\\Managed < drive >:< projectOutFolder > \\ < projectName > _Data \\ Managed

I checked the UnityEngine.dll and the Eventsystems/UI namespace is not included. 我检查了UnityEngine.dll,并没有包含Eventsystems / UI命名空间。 Despite, there is a dll in Unity5\\Editor\\Data\\UnityExtensions\\Unity\\GUISystem\\UnityEngine.UI.dll which includes these namespaces. 尽管如此,Unity5 \\ Editor \\ Data \\ UnityExtensions \\ Unity \\ GUISystem \\ UnityEngine.UI.dll中还有一个包含这些命名空间的DLL。

You can try: 你可以试试:

right click on "project panel", and after "Reimport All". 右键单击“项目面板”,然后“重新导入全部”。

It's can be happen due to switch between platforms, eg IOS, or Desktop.. thus, folrders are deleted by became unecessary.. 这可能是由于平台之间的切换,例如IOS或桌面..因此,folrders被删除成为不必要的..

Solve for me: Unity 5.2, Win 7, 32bits; 解决方案:Unity 5.2,Win 7,32bits;

Good luck! 祝好运!

对于mac,它是/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在运行单元测试时出现以下错误:“ System.NullReferenceException:对象引用未设置为对象的实例。” - Why am I getting the following error: “System.NullReferenceException: Object reference not set to an instance of an object.” when I run a Unit Test? 为什么我使用以下代码获得异常? - Why am I getting an exception with the following code? 我在以下代码中遇到以下错误,该如何解决? - I am getting the following error with the following code, how to fix? 当我返回ObservableCollection时,为什么会出现此超时错误? - Why am I getting this timeout error when I return an ObservableCollection? 实施事件时,为什么会出现无连接错误? - Why am I Getting a no connection Error when I Implement an Event? 为什么我在 VIsualStudio 2017 中使用 ServiceStack 出现错误“类型‘IReturn&lt;&gt;’是在未引用的程序集中定义的” - Why am I getting error "The type 'IReturn<>' is defined in an assembly that is not referenced" using ServiceStack in VIsualStudio 2017 使用C#:断言进行硒测试。 为什么会出现以下错误? - Selenium testing using C#: assertions. Why am I getting the following error? 为什么在以下代码中出现“服务器标签格式错误”错误? - Why am I getting a “server tag not well formed error” on the following code? 在使用EntityFramework编辑关系时为什么会出现错误? - Why am I getting an error when editing relationships with EntityFramework? 覆盖继承的方法时为什么会出现此错误? - Why am I getting this error when overriding an inherited method?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM