Best way to write a custom editor which affects multiple unrelated classes [closed]

1 day ago 2
ARTICLE AD BOX

In Unity, I have a custom editor for my class MyClassA:

using UnityEngine; using UnityEditor; [CustomEditor(typeof(MyClassA))] public class MyClassAEditor: Editor { //Stuff }

I want to make it so that this custom editor also affects MyClassB. How can I do that?

One way I can do it is to have a new editor for MyClassB inherit from this editor, with nothing new written inside of it:

[CustomEditor(typeof(MyClassB))] public class MyClassBEditor: MyClassAEditor { }

While this works, it feels like it might be bad practice in the case that MyClassA and MyClassB are classes which are independent from one another (i.e. one does not inherit from the other). These are two completely independent classes that I just happen to want to draw similarly in the editor.

If that's the case, is this bad practice, and if so, what can I do which is preferable?

Read Entire Article