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);
Debug.Log(so.FindProperty("triggerResults").name);
}
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
{
[System.Serializable]
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);
}
[SerializeField]
internal string gunName = "Default";
[SerializeField]
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.