Variables / Fields Not Appearing in Inspector?

Adding New Fields to the Custom Inspector

The video below will explain how to add fields or variables to the DoorInteractable script as it uses a custom inspector

Code Examples:

  1. Add a field as below into the DoorInteractable script

[SerializeField] private GameObject exampleField = null;
  1. Open the DoorInteractableEditor script - At the top of the script created a new property with the same name like:

SerializedProperty exampleField;
  1. Find the OnEnable() method and add a new find property reference as below:

exampleField = serializedObject.FindProperty(nameof(exampleField));
  1. In the methods below that, find a place for your new field. I've grouped them together to make it more readable. Add a property GUI field:

EditorGUILayout.PropertyField(exampleField);

Understanding Custom Editors:

Below is a ttuorial I made to highlight the usage and examples of custom inspectors / editors

Last updated