I'm able to use a CustomInspector for scripts that I have written. Unfortunately this didn't work for Unity's built in Components (such as Rigidbody, Transform...).
I want to hide everything else and only expose 'mass' but this isn't reflected in the Inspector. Instead, if I go to the 3 dots and click properties, it shows the CustomInspector that I've written.
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(Rigidbody))]
public class RigidbodyEditor : Editor
{
Rigidbody rigidbody;
float mass;
public override void OnInspectorGUI()
{
// base.OnInspectorGUI();
rigidbody = (Rigidbody)target;
mass = EditorGUILayout.FloatField("mass", mass);
if (mass < 0)
{
mass = 0;
}
rigidbody.mass = mass;
}
}
OK just figured out the problem - I named my class RigidbodyEditor which is exactly how Unity names it in their source code. I changed the name to something else and it works perfectly fine.