- Home /
Editor scripts into external assemblies? how?
I have a class that I'd like to have a custom editor for. I have the class working in an assembly DLL ok. Now, how would I go about doing the custom editor? Can I put it into the same assembly? As I get it, it needs to go into (an) Editor folder, so do I have to have two assemblies, one for the main class, one for the editor? Or maybe there's some structure to the assembly itself? So confused!
Hi,
Did you ever succeed with a custom inspector in an external assembly? I'm trying to do the exact same thing as you and can't find anything on how to do it.
Best regards
Answer by rutter · May 12, 2012 at 08:37 AM
This thread has some interesting reading.
That script you're hoping to write a custom inspector for, is it a Unity component type, such as a MonoBehaviour script? I haven't seen any working demos where those are loaded in from external assemblies -- Unity's serialization and so on don't usually play nice in that way -- but that doesn't mean it's impossible.
One suggestion from the thread I just linked was to subclass the external class with your own script, and attach the subclass as a component. If the class you're working with is not a component type, it may be acceptable to create a behaviour script which "manages" an internal instance, and have Unity work through that wrapper layer.
In any case, the basics of writing a custom inspector are surprisingly straightforward:
Extending the editor (manual)
Editor class (script reference)
CustomEditor attribute (script reference)
If you want a more specific answer, it may help to ask a more specific question.
Thanks, I have the class working just fine, it is $$anonymous$$onoBehaviour and it is now in an external assembly, works great. Thing is, I have a separate Editor script to manage a field change for this thing (I have to tweak some internals when a setting changes so it can draw its gizmos ok). It works fine, but is just a normal Editor script. Now I want to hide that Editor script into an assembly too. Eventual target is the Asset Store, so it would be nice to $$anonymous$$imize the number of files for delivery. If I could put the editor script into the same external assembly, that would be keen. I know Editor scripts can go into external assemblies, I just don't know if I need one assembly or two (one for editor, other one for main class).
Ah, I see.
I have to admit that my understanding in this area is not profound. If I had to guess, you'll probably need two assemblies -- any editor script will necessarily reference the UnityEditor namespace, which isn't included in published builds.
Your answer
Follow this Question
Related Questions
After upgrading to 3.4 I sync Monodevlop and now I have 4 different projects in my solution 1 Answer
How to generate Assembly-UnityScript-firstpass.csproj ? 1 Answer
MonoDevelop C# Assembly problem: UnityEngine does not exist in current context. 1 Answer
UnityVS 1.8 possible bug with XML.Linq 1 Answer
How should I add references to additional Mono assemblies? 1 Answer