public static void ReadByte(string scode, com_pixelEdit edit) { try { var src = edit.edit; var p = edit.palette; string strbase64 = System.Uri.UnescapeDataString(scode); byte[] bb = System.Convert.FromBase64String(strbase64); var s = LZMAHelper.DeCompress(new System.IO.MemoryStream(bb), (uint)bb.Length); bb = new byte[s.Length]; s.Read(bb, 0, bb.Length); int seek = 0; int width = bb[seek]; seek++; if (width == 0) { width = 256; } int height = bb[seek]; seek++; if (height == 0) { height = 256; } Debug.Log("w=" + width + ",h=" + height); edit.Resize(width, height); Color32[] pp = src.GetPixels32(0); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { byte ind = bb[seek]; seek++; pp[y * width + x].a = ind; } } src.SetPixels32(pp, 0); src.Apply(); Color32[] ppp = p.GetPixels32(0); int c = bb[seek]; seek++; for (int i = 0; i < c; i++) { byte inde = bb[seek]; seek++; byte r = bb[seek]; seek++; byte g = bb[seek]; seek++; byte b = bb[seek]; seek++; ppp[inde].r = r; ppp[inde].g = g; ppp[inde].b = b; } p.SetPixels32(ppp); p.Apply(); } catch { } }
void TestDeCompress() { try { LZMAHelper.DeCompress(ApplicationdataPath + "/Package_unitypackage.7z", ApplicationdataPath + "/Package_decompress.upk", m_CodeProgress); } catch (Exception ex) { Debug.Log(ex); } }
/// <summary> /// 解压 /// </summary> public void Decompress() { this.progress = 0; new Thread(() => { LZMAHelper.DeCompress(path + "/Enemy/Enemy.zupk", path + "/Enemy/EnemyDe.upk", cp, (str) => { print(str); Release(); //释放完成之后就将isReleaseOver设置为true; isReleaseOver = true; }); }).Start(); //this.StartCoroutine(this.WaitDecompress()); }
IEnumerator WaitDecompress() { yield return(new WaitForSeconds(1)); LZMAHelper.DeCompress(Application.dataPath + "/PackFolder/xml.zupk", Application.dataPath + "/PackFolder/xmlDe.upk", cp); }