Created
May 11, 2015 07:47
-
-
Save tsubaki/5cd0b8a26d9cd6de3f08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example.