Allow creation custom inspectors for 'MonoBehavior' and 'ScriptableObject'

Issue #855 new
Igor Boroda created an issue

Unity allows user to create custom editors for the ‘MonoBehavior’ class by default. But Odin ignores this action. Please remove marked lines (6, 8, 10) from your code. Or all of them.
Path to Odin class: Sirenix\Odin Inspector\Source\Sirenix.OdinInspector.Editor\Config\InspectorTypeDrawingConfigDrawer.cs (lines 170-180)

HashSet<Type> stopBaseTypeLookUpTypes = new HashSet<Type>(FastTypeComparer.Instance)
{
  typeof(object),
  typeof(Component),                  // -> May be to Remove
  typeof(Behaviour),                  // -> May be to Remove
  typeof(MonoBehaviour),              // -> To Remove
  typeof(UnityEngine.Object),         // -> May be to Remove
  typeof(ScriptableObject),           // -> To Remove
  typeof(StateMachineBehaviour),
  typeof(Networking.NetworkBehaviour) // -> To Remove
};

Reason: creation the base custom inspector for all ‘Monobehaviors' gives ability to use custom class attributes like 'description info box drawer’ without creating additional unused fields or custom inspectors for each class in the project.

Example of using description attribute:

[Description("My custom component description. This class don't do anything")]
public class Jumper : MonoBehaviour
{

}

Comments (1)

  1. Antonio Rafael Antunes Miranda

    You can do the same thing by using Odin’s TypeInfoBox attribute, there’s no need to create a completely new editor.
    The way Odin works and the way it encourages you to work is to create small composable drawers. Editors that target MonoBehaviour specifically are not really a good idea since it is very easy to have multiple different editors that target MonoBehaviour which will lead to problems.

  2. Log in to comment