纳金网

标题: 截图保存的代码 [打印本页]

作者: 狂风大尉    时间: 2014-8-31 01:14
标题: 截图保存的代码
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);
   
}

作者: hyui    时间: 2014-8-31 02:21
Thanks for sharing !
作者: kaifly8888    时间: 2014-9-19 22:04
强大的插件谢谢




欢迎光临 纳金网 (http://wwww.narkii.com/club/) Powered by Discuz! X2.5