Search Unity

Use Single Editor Script on Multiple Script Types

Discussion in 'Scripting' started by Rukas90, Jul 12, 2018.

  1. Rukas90

    Rukas90

    Joined:
    Sep 20, 2015
    Posts:
    169
    Hello,

    Recently I've been making some editor scripts in my game. I have multiple scripts (Prop, Tree) that display same parameters on the inspector. These scripts are separate because they behave in a different way, but the editor scripts for all of those scripts are identical. Is there a way to use single editor script for multiple type scripts?
    Like you specify everytime what type of editor script it is

    Code (CSharp):
    1. [CustomEditor(typeof(Tree))]

    Is there a way to use either multiple types or categorize multiple scripts somehow with a custom type or tag and use that?

    Like both scripts derive from an abstract class, I tried to specify that, but it didn't work.

    It's a bit weird question I know, but I don't know how to explain it better.. Thank you.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    You might be able to set it to an interface and create your own. I know the inspector supports interfaces.