Search code examples
c#unity-game-enginedrawerunity-editor

Unity PropertyDrawer applied to children who have own PropertyDrawer


I've a series of classes:

public class A<T> : ScriptableObject {}

public class B : A<int> { }

public class C : A<float> { }

public class D<T> : A<T> { }

public class E : D<int> { }

And I've two Drawers:

[CustomPropertyDrawer(typeof(A<>), true)]
public class ADrawer : PropertyDrawer { }

[CustomPropertyDrawer(typeof(D<>), true)]
public class DDrawer : PropertyDrawer { }

The problem is that ADrawer is applied to E objects too instead of DDrawer also if I make

[CustomPropertyDrawer(typeof(E), true)]
public class EDrawer : PropertyDrawer { }

Any suggestion?


Solution

  • Okay, solution is: put the two Drawers in different namespaces. Example:

    namespace FakeNamespace.Drawers
    {
        [CustomPropertyDrawer(typeof(A<>), true)]
        public class ADrawer : PropertyDrawer { }
    }
    
    namespace FakeNamespace.Drawers.Others
    {
        [CustomPropertyDrawer(typeof(D<>), true)]
        public class DDrawer : PropertyDrawer { }
    }