How would I convert the following XNA script to UnityScript:
private Texture2D CreateStaticMap(int resolution)
{
Random rand = new Random();
Color[] noisyColors = new Color[resolution * resolution];
for (int x = 0; x < resolution; x++)
for (int y = 0; y < resolution; y++)
noisyColors[x + y * resolution] = new Color(new Vector3((float)rand.Next(1000) / 1000.0f, 0, 0));
Texture2D noiseImage = new Texture2D(device, resolution, resolution, 1, TextureUsage.None, SurfaceFormat.Color);
noiseImage.SetData(noisyColors);
return noiseImage;
}
I tried but got a handful of errors:
var resolution : int;
function Start(){
CreateStaticMap();
}
function CreateStaticMap(){
var noisyColors : Color[] = new Color[resolution * resolution];
for(x=0; x<=resolution; x++){
for(y=0; y<=resolution; y++){
noisyColors[x + y * resolution] = new Color(Vector3(System.Random.Next(1000) / 1000.0, 0, 0));
}
}
var noiseImage : Texture2D = new Texture2D( //I have no idea what to do now
}