Can anybody help check whats wrong with my code, the error given is:
Could not create texture from Assets/Textures/1x1 0,0,0.png: File could not be read
EDIT: Got it working, changed the code below. (This is a editor only script)
void CreateColorPicture(Color color) {
Texture2D tex = new Texture2D(1,1);
tex.SetPixel (1, 1, color);
tex.Apply();
if(!Directory.Exists(Application.dataPath+"/Textures/")) {
Directory.CreateDirectory(Application.dataPath+"/Textures/");
}
byte[] bytes = tex.EncodeToPNG();
DestroyImmediate(tex);
File.WriteAllBytes (Application.dataPath + "/Textures/1x1 "+(color.r * 255).ToString()+","+(color.g * 255).ToString()+","+(color.b * 255).ToString()+".png", bytes);
}
It is meant to create a 1x1 picture with the given color.