- Home /
 
 
               Best Answer 
              
 
              Answer by Senhor de todo o Mal · Jun 27, 2011 at 09:15 AM
Check the scripting reference.
All the information is there.
The code in c# would be something like this:
 Color[,] 2dArray;
 Texture2D texture;
 //texture initialization
 //array initialization
 
 int width = 2dArray.GetLength(0);
 int height = 2dArray.GetLength(1);
 Color[] 1dArray = new Color[width*height];
 Color color;
 for(int i = 0; i < height; i++){
   for(int j = 0; j < width; j++){
     color = 2dArray[j,i];
     1dArray[i*height+j] = color;
 
   }
 }
 texture.SetPixels(1dArray);
 texture.Apply();
 
              Answer by kennypu · Jun 27, 2011 at 09:03 AM
I'm not sure how you would do it exactly in c#, but I can give the concept. Just use a nested forloop to grab each of the elements from the 2D array, and put them in a 1D array. This will only work though if the 2D array has fixed number of elements in each spot
Your answer