FindObjectsOfType

It seems to me that I should be able to do something like this:

var glist = FindObjectsOfType(Globals);

if(glist.length > 1){
  Delete(this);
}

It seems like FindObjectsOfType is supposed to return an array, but Unity says “MissingFieldException: Cannot find variable length.”

Usually (always? :-/ ) properties in .NET are capitalized, so try glist.Length .

Cheers,
-Jon

Hmm…

The documentation says “length”.

The editor highlights “length” but not “Length”.

But “Length” appears to work :-/

I guess that is due to the confusion that was engineered when they implemented JavaScript Arrays to be in addition to builtin Mono arrays. Builtin ones are capitalized Length, JavaScript ones are length. The Unity functions return builtin Mono arrays. Wooo hoo! :shock:

-Jon

Ulp :?