C# <<-->> Dll problem...

Hello after the news that unity supports managed dll’s i started working on porting my current AI Editor into DLL’s but i got 1 problem till now…

I get the errors from this block of the code…

public static void Init ()
	{
		GetWindow (typeof(AIEditor));
	}

The Generated Errors are:
“Instance of AIEditorcouldn’t be created because there is no script with that name.
UnityEditor.EditorWindow:GetWindow(Type)
MyWindow:Init()”

“NullReferenceException: Object reference not set to an instance of an object
UnityEditor.EditorWindow.GetWindow (System.Type t, Boolean utility, System.String title, Boolean focus) (at E:/BuildAgent/work/71ca6fec1b41cc30/Editor/Mono/Generated/EditorWindow.cs:256)
UnityEditor.EditorWindow.GetWindow (System.Type t) (at E:/BuildAgent/work/71ca6fec1b41cc30/Editor/Mono/Generated/EditorWindow.cs:242)
AIEditor.Init ()”

Oh and i have to mention that the code is in a Dll and it was designed to create a Editor Window

Best Regards

Is the AIEditor class defined within a namespace? As far as I know, there haven’t been any changes in Unity’s ignorance of namespaces. If it’s in the default namespace, though, it’s possible Unity still has some gaps in its support for DLL-hosted code; I haven’t tried to migrated any EditorWindow classes back out to the DLLs they properly belong in since the announcement.

tried both …defined within a namespace and using the defaul one …same errors

Does anyone have a solution to this?

The solution is not to try and migrate sub-classes of EditorWindow into a DLL, as this is still not fully supported. The best you can so is still to have a script that’s a thin wrapper for the class in the DLL, and reference the wrapper in all calls which request Unity to instantiate the class).

What Laurie said. Basically we have support for MonoBehaviour derived classes in assemblies, but not so for ScriptableObject derived ones.

What I am doing is as described above. I define an interface in the assembly which a thin EditorWindow derived wrapper class (living as a script file in the project assets) implements.

Once this wrapper class gets instantiated, it instantiates the core class implemented in the assembly, passing a reference to itself to the constructor of this. Communication between the proxy and the main then happens through these two references.

Sorry to dig up such an old thread but I understand it is now possible to put EditorWindows in DLLs…? However I can’t find info on the earliest version of Unity that allowed it. It doesn’t seem to work in 3.5.0. I’d like to support the oldest version of Unity possible…

It works with Unity 3.5.7 for sure.

What you have to pay attention for is to try to export your game from time to time to see if you have the clear separation between your editor code and “runtime” code. If not, Unity will not want to export your game. That’s because it ignores all the editor code when exporting.

Another important thing is that your editor DLL must reside in the “Editor” folder. Or “whatever/your/path/is/Editor” folder. Unity then merges all the Editor folders together.

Danko