- Home /
C#: Include Custom Editor features for a custom Classes while avoiding dependencies?
Hello,
First, apologies if this has already been answered, but my searches have failed me.
My question: How would one approach creating a custom Editor tool with support for custom classes, without creating a dependency on said classes?
I'm creating a code generation tool, and wish support a various custom classes (Int3, IntCurve, etc.). If the classes are present, they will require editor scripts to process them and will need to be include in a handful of arrays.
What are best-practices for a situation like this?
In other situations, I've used partial classes, but I've been unable to structure this tool in such a way that would work.
Thank you all in advance! Be well!
- S.
I've never done this, but you can try using dependency inversion or "inversion of control". In other words, you would reference an interface ins$$anonymous$$d of a class type. I'm not sure it works though, classes will have to implement that interface.
You can otherwise have a look at Reflection, with custom attributes.
Hm. Inversion of control might be difficult, given that these editor scripts work with both custom classic and Unity's built-in classes. Having them share an Interface would also create a dependency between the custom classes and the Interface, which isn't optimal either.
I hadn't considered reflection, though. I've only barely dabbled in it, but I'll have to take a deeper look and see if that might lead to a solution.
Thank you for the thoughts!
If you haven't, I'd suggest looking into property drawers which let you: Customize the GUI of every instance of a Serializable class. Customize the GUI of script members with custom Property Attributes.
Responding to the presence of a class instance inside of an inspected GameObject is a little trickier, but seems doable from what I've seen.
Your answer
Follow this Question
Related Questions
Find public assigned values using editor script 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to resave generated meshes with Editor Scripts? 0 Answers
Get gameobject gizmo icon by script 0 Answers