Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created January 17, 2013 13: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/4556005 to your computer and use it in GitHub Desktop.
Save tsubaki/4556005 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System.IO;
public class LoadTexture : MonoBehaviour {
[SerializeField] string fileName = "icon";
[SerializeField] GUITexture gui;
IEnumerator Start () {
string path = "file://" + Path.Combine( Application.streamingAssetsPath , fileName);
using(WWW www = new WWW(path))
{
yield return www;
Texture2D tex2d = www.texture;
tex2d.Compress(true);
gui.texture = tex2d;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment