SerializedObject.FindProperty() returning null for internal List<> field

Hi, I’m currently writing a custom editor class and I would like to display a property field in the inspector but whenever I call SerializedObject.FindProperty() it doesn’t seem to work.

Here is the code for the OnInspectorGUI() function inside of PlayerGunEditor

public override void OnInspectorGUI()
    SerializedObject so = new SerializedObject(target);

and here is the property field inside of PlayerGun. It’s a list of TriggerResult objects, which is an internal class inside of PlayerGun

public class PlayerGun : ScriptableObject
	internal abstract class TriggerResult
		internal Vector2 spawnPosition;
		internal float spawnRotation;
		internal ColorId spawnColor = ColorId.CurrentColor;
		internal ColorId spawnIfSelected = ColorId.CurrentColor;
		internal abstract void Populate(ref GameObject gameObject);

    internal string gunName = "Default";

    internal List<TriggerResult> triggerResults = new List<TriggerResult>();

The problem here is that so.FindProperty(“triggerResults”) returns null, and I for the life of me can’t figure out why. Does anyone have some insight on why this might be or what I’m doing wrong? For reference, so.FindProperty(“gunName”) returns the property expected. Thanks.

Hi! TriggerResult is a custom abstract class, and therefore Unity’s serializer cannot serialize it (see here). Depending on exactly what you need to do, there are various options for the ideal way to approach it.

Also, for future reference, the Editor class has a property, serializedObject, which is already initialized for all targets in the selection, so no need to create that inside of OnInspectorGUI() :wink: