How come this code generates a "cannot cast from source type to destination type" error on the line that prints?
var aircraftObjects = [
"Fuselage",
"Left Alier",
"Left Eleva",
"Left Horiz",
"Left Wing",
"Right Alie",
"Right Elev",
"Right Hori",
"Right Wing",
"Rudder",
"Vertical S"
];
for (var i in aircraftObjects)
{
print(aircraftObjects*);*
*}*
*```*
Jessy
2
That's not how you use a for - in. loop. This is.
for (aircraftObject in aircraftObjects) print(aircraftObject);
Or, if you want to be really clear about things,
for (var aircraftObject : String in aircraftObjects) Debug.Log(aircraftObject);
Why Unity doesn't warn you about this, I don't know.