Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created May 11, 2015 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/5cd0b8a26d9cd6de3f08 to your computer and use it in GitHub Desktop.
Save tsubaki/5cd0b8a26d9cd6de3f08 to your computer and use it in GitHub Desktop.
#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
Copy link
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