Hi. Got a problem.
I’ve got this code (troll is a type of tank if anyone asks):
class Indinces {
var i = new Array ();
function Indinces (things : GameObject[], startIn : Array) {
if (things.Length > 0) {
for (thing in things) {
var thingVar = Diggers (thing);
i.Push (thingVar);
}
for (t = 0; t < i.length; t++) {
for (sv in startIn) {
i[t].v.Add (sv);
}
}
}
}
}
class Diggers {
var o : GameObject;
var v = new Array ();
var e = new Array ();
function Diggers (oo : GameObject) {
o = oo;
}
}
function Update () {
tanks = GameObject.FindGameObjectsWithTag ("Tank");
trollRockets = GameObject.FindGameObjectsWithTag ("RocketTroll");
var indinces = new Array (); //contains ints
var iTanks = Indinces (tanks, indinces);
var iRockets = Indinces (trollRockets, indinces);
for (/*stuff*/) {
var iTanks2 : Diggers[] = iTanks.i.ToBuiltin (Diggers) as Diggers[];
for (tankClear in iTanks.i) {
tankClear.v.Clear ();
}
var iRockets2 : Diggers[] = iRockets.i.ToBuiltin (Diggers) as Diggers[];
for (rocketClear in iRockets.i) {
rocketClear.v.Clear ();
}
//this is where problems start*
*after this, the “o” object is still there, but the “v” array is empty. Maybe a chance that it was lost while Array.ToBuiltin ()?
Thanks for reading this far.
EDIT: Same problem with Generic Lists.