在这里,我尝试将纹理另存为图片。但是程序没有响应。并且图片不出现。为什么?
void Start () {
SceneSettings = GameObject.Find("Scene Settings");
boardScript = SceneSettings.GetComponent<BoardScript>();
}
public void DownloadOptionsFunction()
{
FullImageTexture = new Texture2D(pixelsQuality * boardScript.width, pixelsQuality * boardScript.height);
for (int y = 0; y < boardScript.height; y++)
{
for (int x = 0; x < boardScript.width; x++)
{
Color color = boardScript.PixelElement[boardScript.width * y + x].GetComponent<Image>().color;
for (int y2 = y * pixelsQuality; y2 < pixelsQuality * (y + 1); y2++)
{
for (int x2 = x * pixelsQuality; x2 < pixelsQuality * (x + 1); x2++)
{
FullImageTexture.SetPixel(x2, y2, color);
}
}
}
}
FullImageTexture.Apply();
System.IO.File.WriteAllBytes(Application.dataPath + "/" + boardScript.name, FullImageTexture.EncodeToPNG());
}