Another day, another question! Still going round in circles in my quest for a custom inspector and after battling the lack is an isNull method in C# I find myself in the present situation -
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[System.Serializable]
public class InteractiveNPC : MonoBehaviour {
public ArrayList dialogueStore = new ArrayList();
public int dialogueCount = 0;
...
Now, according to the documentation - http://unity3d.com/support/documentation/ScriptReference/SerializeField.html (SerializeField is irrelevant, however this page contains the list of serialisable objects) - Serialisable Arrays are serialisable in Unity. Lovely, so I checked that ArrayLists are serialisable and lo, MSDN - http://msdn.microsoft.com/en-us/library/system.collections.arraylist(VS.71).aspx - confirms that ArrayLists are serialisable, so in theory, I should be all good.
But then my question is, why does this happen:
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
[CustomEditor(typeof(InteractiveNPC))]
public class InteractiveNPCInspector : Editor {
SerializedObject obj;
SerializedProperty dialogueStore;
SerializedProperty dialogueCount;
private ArrayList localStore = new ArrayList();
void OnEnable() {
obj = new SerializedObject(target);
Debug.Log("Object: " + obj);
//Object: UnityEditor.SerializedObject
dialogueStore = obj.FindProperty("dialogueStore");
Debug.Log("Store: " + dialogueStore);
//Store:
dialogueCount = obj.FindProperty("dialogueCount");
Debug.Log("Count: " + dialogueCount);
//Count: UnityEditor.SerializedProperty
}
...
Given I can retrieve the object itself, and the int property, why doesn't the ArrayList get retrieved? And also, why does it silently fail (until I try to use it..).
Answers on a postcard!