Required inspector variables

Hate not being able to know I accidentally didn’t drag a gameobject to a inspector variable slot until the script is enabled, which may not happen until I run into an encounter that needs that script to be active.

Anyone know of a good to check for inspector variables set to null on startup without having to write custom checks for each variable? The only thing I can think of so far is creating a “SmartMonobehavior” class that Monobehavior derives from and checks for any variables with a “Required” custom c# attribute via reflection in a virtual Start function. This means, however, that I have to verify every derived class calls this base function.

PropertyAttribute with CustomPropertyDrawer wouldn’t work for you? with this you can create custom attribute with support from Unity engine… (e.g. CustomPropertyDrawer has ‘fieldInfo’ field so u can access to property with your attribute)

You can always make null more obvious in the Inspector, or give a default value in your code… But forgetting to click on the object and editing it… nah, no real way.