【发布时间】:2016-08-30 21:40:19
【问题描述】:
这是我的代码:
sigTex = new Texture2D ((int)dims.x, (int)dims.y);
sigTex.ReadPixels (new Rect (new Vector2(0.0f, Screen.height - bot) , dims), 0, 0);
byte[] pngBytes = sigTex.EncodeToPNG ();
System.IO.BinaryWriter bw= new System.IO.BinaryWriter(new System.IO.FileStream(filename, System.IO.FileMode.Create));
bw.Write (pngBytes, 0, pngBytes.Length);
bw.Close ();
问题是,在这段代码之后,当我尝试在 GUI 中使用它或在检查器中查看它时,我留下了一个统一灰色的空白纹理。 奇怪的是生成的文件是正确的。
【问题讨论】:
-
能否提供在 UI 元素上应用纹理的代码?
-
我相信这是问题所在显示。 GUI.DrawTexture (new Rect (cursor, GUIConstanst.flatRect), sigTexture, ScaleMode.ScaleToFit);
-
如果以下答案有帮助,请考虑勾选答案。谢谢