- Home /
Cant link PLUGIN.DLL with PLUGIN-EDITOR.DLL
I need help: I DONT FIND the proper way to split an existing working plugin int 2 dlls, can anyone help me?
I am spliting the original project into 2 projects: (runtime & editor)
- the runtime does not contains any editor-related code, and it creates the RUNTIME.DLL
- the editor project does not contains the runtime classes but it includes the RUNTIME.DLL reference and only contains all the Inspector files
I build runtime, then the editor.
It compiles, on Unity it recognizes the runtime scripts, and it recognizes some [MenuItems("tool")] from the editor.dll but it doesnt actually links both plugins...
Everytime I select an object, it shows an error about not finding the correct inspector
ERROR: Failed to load CustomEditor inspected type
UnityEditor.AssetPreviewUpdater:CreatePreviewForAsset(Object, Object[], String)
LOG: Can't load custom inspector theObjectInspector because the inspected type is null.
UnityEditor.AssetPreviewUpdater:CreatePreviewForAsset(Object, Object[], String)
This is how I place the dlls in Unity:.
Assets
. . .└ Plugins
. . . . . .└ plugin.DLL (the runtime)
. . . . . .└ Editor
. . . . . . . . . .└ plugin.DLL (the editor)
Am I setting wrong the VS project?
Am I setting wrong the Unity settings?
Why both dlls works but they cant find each other?
I already searched in every thread ( this is the most similar post , I tried, but still no fix for me)
Thanks a lot for your help!
Answer by yaaashua · Nov 20, 2018 at 07:37 PM
After a lot of pain and time I found several reasons:
- if you the referenced dll (plugin.dll) name contains empty spaces... IT WILL NOT WORK.
this is so ridiculous and I havent seen any warning about it.
variable initializations on the same line than declaration WILL NOT WORK.
...and most probably something will point to null and throw errors.
In normal scripts this is fine, when is split, variables doesnt get initialized (so initialize them in awake or something)
There are some old posts saying that you should create a proxy classes... I this is not necessary since many years ago.
Visual studio projects need only the dll references ( runtime needs UnityEngine) (Editor project needs UnityEngine, UnityEditor and your runtime.dll) (like in the question)
Unity project: only needs the dll in the expected folders (same as in the question)
Do not ask me why this happens... I just found out it does.
What helped me a lot is to reduce the code to the most simple code (and dlls) as possible and crying for days