I'm trying to create an editor script to edit data contained within a sequence of objects; the best way to do this would of course be to contain these objects within a dynamic list (as opposed to a static array, which works). The problem is that as lists can a wide variety of objects, I've been getting compiler errors when I try to access a member variable of one of the list items: Assets/Editor/ConversationTreeEditor.boo(10,22): BCE0019: 'name' is not a member of 'object'.
I believe that there's a way to typecast member objects of a list in C# (List nodes = new List (); - right?), though I'm not sure how to do that in Boo. I have come up with the following code, which should not cause any run time errors (accessing member variables is bypassed if the given object doesn't pass a typecheck), but it has been unable to pass Unity's debugging system. Same goes for try/except blocks.
import UnityEngine
import UnityEditor
[CustomEditor(ConversationTree)]
class ConversationTreeEditor (Editor):
def OnInspectorGUI ():
for node in target.nodes:
if node isa ConversationNode:
node.name = EditorGUILayout.TextField("Name", node.name)
if GUILayout.Button("+"):
newNode = ConversationNode()
target.nodes += [newNode]
Since I can't run any of my code if I have compiler errors (Unity 3 made sure of that), this problem has brought my work to a grinding halt. I'm at a bit of a loss here... any suggestions?