Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#pragma strict
import System.IO;
function OnGUI()
{
if( GUI.Button(Rect(0, 0, 100, 100), "load") )
{
StartCoroutine(Load());
}
}
function Load()
{
var zipPath = Application.temporaryCachePath + "/tempZip.zip";
var exportPath = Application.temporaryCachePath + "/unzip";
var imagePath = exportPath + "/twitter_icon.png";
var www = new WWW("https://dl.dropboxusercontent.com/u/56297224/twitter_icon.png.zip");
yield www;
var data = www.bytes;
File.WriteAllBytes(zipPath, data);
ZipUtil.Unzip(zipPath, exportPath);
var tex = new Texture2D(1, 1);
var imageData = File.ReadAllBytes(imagePath);
tex.LoadImage(imageData);
GetComponent.<UnityEngine.UI.RawImage>().texture = tex;
File.Delete(zipPath);
Directory.Delete(exportPath, true);
}
@tsubaki

This comment has been minimized.

Copy link
Owner Author

tsubaki commented May 11, 2015

Example.

  1. Open Sample.unity (https://github.com/tsubaki/UnityZip/tree/Sample)
  2. download and import this script.
  3. Change component UnzipAndRead -> UnzipAndReadJS (UnzipAndRead is attached in Canvas/RawImage object)
  4. Play then download , unzip, and show image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.