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

19.5k views Asked by At

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. The code that would be compiled contains references to UnityEngine.UI and UnityEngine.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'. 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. 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.

As a side note, I have posted this question to Unity Answers and have yet to receive a response. I expect it's because assembly compilation is beyond the scope of what most users there choose to undertake. Hence my asking it here.

4

There are 4 answers

0
AudioBubble On BEST ANSWER

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. Unity projects have this by default (see below).

This is verified by opening up the assembly in your reflector tool of choice, here I am using JetBrains dotPeek:

enter image description here

This is how my test project appears with default Unity references. Note that by default a reference to UnityEngine.UI already appears in the Unity-created project:

enter image description here

When I built my Windnows desktop app via Unity, the above dlls appeared in:

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

3
Marius Junak On

I checked the UnityEngine.dll and the Eventsystems/UI namespace is not included. Despite, there is a dll in Unity5\Editor\Data\UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll which includes these namespaces.

1
Leonardo Lanzellotti On

You can try:

right click on "project panel", and after "Reimport All".

It's can be happen due to switch between platforms, e.g. IOS, or Desktop.. thus, folrders are deleted by became unecessary..

Solve for me: Unity 5.2, Win 7, 32bits;

Good luck!

0
Hustlion On

For mac, it's /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll.