Quantcast
Channel: Questions in topic: "dll"
Viewing all articles
Browse latest Browse all 706

How to: Conditional use of UnityEditor In DLL?

$
0
0
I’m attempting to create a simple utility function DLL, but seem to be running into dependency issues in general and an argument exception specifically, when I try to “build&run” the project that uses this DLL. The issue arises because I want certain code from the DLL executed when in the editor, and other code, when not in the editor (built project). E.g. using `DestoryImmidiate()` when in the editor and not in play-mode, and `Destroy()` otherwise. I’ve attempted using the [`Conditional`][1] attribute in the DLL, as well as pre-processor pragmas('#if UNITY_EDITOR`). Alas, even with everything else compiling and running ok, the lack of UnityEditor.DLL being allowed in the output "build" prevents it from compiling and generates the following ArgumentException. ArgumentException: The Assembly UnityEditor is referenced by EditorTools ('Assets/EyeEngines/EditorTools.dll'). But the dll is not allowed to be included or could not be found. Is it possible to put conditional UnityEditor code like this into a DLL? If so, how? One obvious workaround is to create TWO versions of the DLL (one with the UNITY_EDITOR pragma defined, one with it undefined), but unless Unity has some way to automatically use the right one, I don’t like it: too confusing for users of the dll (Initial tests of this method generated "class redefined" compilation errors in editor.) [1]: https://msdn.microsoft.com/en-us/library/system.diagnostics.conditionalattribute(v=vs.110).aspx

Viewing all articles
Browse latest Browse all 706

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>