- Home /
Question by
superventure · Jun 17, 2013 at 05:48 AM ·
waypointshandleslabels
Trying to understand editor scripts
Im trying to get a label to pop up over every child in any gameobject with the 'drawlinetryout' script on it- so what am I doing wrong? the waypoints var is a transform[] in the drawlinetryout script. It keeps throwing me error messages.
@CustomEditor (drawlinetryout)
class LabelHandle extends Editor {
function OnSceneGUI () {
Handles.color = Color.black;
//for (var child : Transform in transform) {
var script = new SerializedObject(target);
var waypoints:Transform [] = script.FindProperty("waypoints");
for ( i = 0; i < waypoints.Length; i++)
//Handles.Label(target.transform.position + target.transform.up *.5, target.transform.name.ToString());
Handles.Label(waypoints[i].position + waypoints[i].up *.5, waypoints[i].name.ToString());
}
}
Comment
Best Answer
Answer by Bunny83 · Jun 17, 2013 at 06:01 AM
I'm on my tablet so I can't write a full sample, but this should get you on the right track:
The SerializedProperty can't be casted into an array. You have to use the functions it provides, especially: