I am preparing a submission for the asset store. Beside the runtime classes it contains a lot of editor scripts. I would like to bundle those editor scripts in a dll, but not the runtime classes. AngryAnt describes nicely how to create dll’s for runtime and editor scripts together, but I don’t know how to use it for editor scripts only.
Thats possible only within limited borders. You can put your whole editor code in the dll but you need to have the editor / editor window extending classes as plain code in unity or it won’t work (so called proxy classes). these then would be near empty skeletons calling the functionality inside the assembly
I would be very thankful for a hint. If I am compiling the editor scripts only using the following command (simplified version):"C:\Program Files\Unity\Editor\Data\Mono\bin\gmcs.bat" -target:library -out:smile:llTesting.Editor.dll Editor\*.cs -d:UNITY_EDITOR -r:"C:\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll" -r:"C:\Program Files\Unity\Editor\Data\Managed\UnityEditor.dll" -resource:Editor\Resources\*.png
several errors are shown. All look as follows:
Editor\AClassEditor.cs(7,11): error CS0246: The type or namespace name `AClass' could not be found. Are you missing a using directive or an assembly reference?
I understand that the compilation command does not point it to the other scripts and thus the compiler doesn’t know that code. How can I point it to that code? I don’t want to have the runtime code in another dll and user another -r: to that dll.
Is the dll in the root Unity folder? (Not the Assets folder, but the root: C:\Program Files (x86)\Unity_3_3\Editor)
Or, is it in the “Editor” folder under assets?
I’m not sure the root is a requirement for editor dll’s, but it is for runtime dlls.
Ah I see.
Well there I would normally not use command line but either Visual Studio or MonoDevelop and create a new assembly project there, code the stuff, configure the release build to target into the Editor folder and then just build it.
You’ve got a bunch of editor classes which need to reference some runtime classes.
Your runtime classes stand just fine on their own - not referencing the editor classes in any way.
The appropriate build setup should be this:
Build all runtime classes into MyRuntime.dll, referencing UnityEngine.dll.
Build all editor classes into MyEditor.dll, referencing UnityEngine.dll, UnityEditor.dll and MyRuntime.dll.
Move MyRuntime.dll to your project assets folder and MyEditor.dll to a path in the assets folder with “Editor” somewhere in it. For Behave I use /Assets/Behave/Behave.Runtime.dll and /Assets/Behave/Editor/Behave.Editor.dll.
As dremora mentioned, ScriptableObject derived classes (that includes EditorWindow) cannot be instantiated from assemblies and will therefore need a proxy setup as he describes. MonoBehaviour derived classes can live in assemblies just fine.
You could set it up like that, by referencing the dll built from the scripts by Unity, when you build your editor dll. Wouldn’t be pretty, but could work.
It would be a lot easier to manage if you mode AClass.cs into an assembly as well though.
Thanks AngryAnt. I am going to make it like that, if the following is still possible:
Can it still be used for web player builds? Will it also work without pro license?
dreamora, sure the editor classes are not in the builds. The runtime classes would be in a dll, too. My question was, if that is a problem. But as you say, it works, I am going to make it like that.
Assemblies are simply included in builds. The same rules apply to them as any script file placed in the assets folder. Regarding resources included in the assembly, those are just an available byte stream and are unaffected by the Unity build process.