- Home /
Array.Copy in UnityScript
var a1 = new Array();
var a2 = new Array();
Array.Copy(a1 ,0 , a2 ,0, 1);
.>>'Copy' is not a member of 'Array'.
How can I copy an array in UnityScript?
Answer by robertbu · Jul 27, 2014 at 03:43 PM
Don't use the Array class. It is untyped and slow and the source of numerous questions on UA because of its untyped nature. If your data is of fixed size, then use a build-in array, which can be copied using System.Array.Copy(). If you need something of variable size, use one of the .NET generic collections like the List class (which has a Copy() method).
http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use%3F
The Array class is never what anyone needs. ;) If someone really needed an untyped collection, then a built-in array or generic List using the Object type would work better, so Array is quite useless.
Your answer
Follow this Question
Related Questions
Copy From Array to List without reference [C#] 2 Answers
Copy Lightmap Script error meta files 0 Answers
Storing Inventory Item Properties 2 Answers
How do you debug arrays of objects? 1 Answer