Hello,
I’m trying to build a very simple Reorderable List of type GameObject, but I can’t get my head around it, in my script of MonoBehaviour, I have a list:
public List<GameObject> MyGameObjects = new List<GameObject>();
And within my Editor script (typeof above script):
private ReorderableList _list;
private void OnEnable() {
_list = new ReorderableList(
serializedObject,
serializedObject.FindProperty("MyGameObjects"),
true, true, true, true);
_list.drawElementCallback = (Rect rect,
int index,
bool isActive,
bool isFocused) => {
var element = _list.serializedProperty.GetArrayElementAtIndex(index);
EditorGUI.PropertyField(new Rect(rect.x,
rect.y, 60, EditorGUIUtility.singleLineHeight),
element.FindPropertyRelative("GameObject"));
};
}
The problem lies within ‘FindPropertyRelative’ I believe. This gives me the error: Object reference not set to an instance of an object?
Thanks.