What array-type does GetComponents return?


in my code I have:

speedParameters = GetComponents."tag" ParameterSpeed "tag"();

I’m using the generic “GetComponents” function and it returns a valid array.

What I want to know is:

  1. What type of array does GetComponents return (by “type” I mean built-in or normal)? The documentation doesn’t state this.
  2. more generally: how can I check what type of array an array is?
  3. If the array isn’t built-in, how can I specificly convert it into a built-in one to improve performance?


1.) GetComponent returns a builtin array as you can see from the syntax (Component****)
2.) are builtin arrays, Array to Javascript arrays.
3.) Please see here: http://docs.unity3d.com/Documentation/ScriptReference/Array.html

Hope that helps

As far as I know, Unity functions always return built-in arrays - any other array type would be more expensive. Anyway, you can use .GetType() to get a string describing the complete type: built-in arrays return things like “System.Int32”, while a List returns “System.Collections.Generic.List…” - for instance:

var myArray: int[] = new int[100];

print("myArray type = "+mayArray.GetType());

You can convert from Unityscript Array class (veeery slow and problematic) to builtin with ToBuiltin:

 var builtinArray : Vector3[] = array.ToBuiltin(Vector3);