Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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.

like image 567
APalmer Avatar asked Jun 09 '15 04:06

APalmer


3 Answers

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

like image 102
MickyD Avatar answered Oct 22 '22 17:10

MickyD


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!

like image 22
Leonardo Lanzellotti Avatar answered Oct 22 '22 16:10

Leonardo Lanzellotti


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.

like image 2
Marius Junak Avatar answered Oct 22 '22 16:10

Marius Junak