WWW对加载的图片进行压缩
使用例子:
WWW www = new WWW ("file:///" + ToolSDK.MsLocalFilePath + "/" + MsID + ".jpg");
yield return www;
if (www.error != null) {
Debug.Log ("本地图片加载失败:" + www.error + "记载本地路径为:" + (ToolSDK.MsLocalFilePath + "/" + MsID + ".jpg"));
} else {
if (www.isDone) {
this.transform.GetChild (0).GetComponent<UITexture> ().mainTexture = new Texture2D (4,4,TextureFormat.PVRTC_RGB4,false);
www.LoadImageIntoTexture ((Texture2D)this.transform.GetChild (0).GetComponent<UITexture> ().mainTexture);
}
}
注意一:先对需要替换图片的物体进行压缩设置
注意二:通过LoadImageIntoTexture将图片放置到物体上