Static Array Empty in 1 script but not the other...

I am at a lost…

That is my array in one script :

GameManager (GameObject holding the arrays) :

static var celListT2Empty		: Array = new Array();

GameObject 1

var celListT2Empty : Array	;
function Update (){
celListT2Empty 	= GameManager.celListT2Empty ; 
print(celListT2Empty.length);
}

GameObject 2:

var celListT2Empty : Array	;
function Update (){
celListT2Empty 	= GameManager.celListT2Empty ;
print(celListT2Empty.length);
}

Game Object 1 prints 27 : number of cels in the array properly… GameObject 2 prints 0 … What am i mising ?

No clue, the code you’re looking at seems fine, but why re-assign the reference every update, why not just use the static array directly?

print(GameManager.celListT2Empt.length);

At first it was in a function called once during the Awake, i put it in update to see what i was missing…
Let’s try to print like you said without re-assigning, be right back.

Edit : Still shows 0… I seriously don’t get it…

Edit 2 : Nevermind, i was just being stupid… i was adding the gameobject to the list but removing them right after. So it showed properly in gameobject 1, then remove it, then try gameobject 2; showed 0…

Sometimes i just fail at logic.

Cameron, would you have any idea how to get the gameObject from the array ?

findCel=false															;
	print("Find Cel")														;
	length = GameManager.celListT2Empty.length								;
	print(length)															;
	var cel = Random.Range(0, length)										;
	targetCel = GameManager.celListT2Empty[cel]								;
	moveToCel=true															;

That is giving me back an " Invalid cast location " .

No clue, this is precisely why I dislike UnityScript/Javascript.

C# is typesafe and has generic collections and just generally makes more sense to me. Unityscript is a bit too lax with what any variable type could be.

public List myGameObjectList; // Leaves no room for mistakes