- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
private var fileName : String = "screenShot";
function writeFile()
{
var tex : Texture2D= new Texture2D(Screen.width,Screen.height,TextureFormat.RGB24, false);
tex.ReadPixels(Rect(0,0,Screen.width,Screen.height),0,0);
tex.Apply();
var bytes : byte[]=tex.EncodeToPNG();
Destroy(tex);
var thisName : String = fileName+".png";
var cachedAssetBundle =Application.dataPath+"/Resources/"+thisName;
var cache = new System.IO.FileStream(cachedAssetBundle, System.IO.FileMode.Create);
cache.Write(bytes,0,bytes.Length);
cache.Close();
Debug.Log("Cache saved: "+cachedAssetBundle);
}
|
|