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!
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.