Skip to content

Instantly share code, notes, and snippets.

@DanMillerDev
Created March 9, 2018 03:51
Show Gist options
  • Save DanMillerDev/b8b86c3503efa904b46ca488de2834b4 to your computer and use it in GitHub Desktop.
Save DanMillerDev/b8b86c3503efa904b46ca488de2834b4 to your computer and use it in GitHub Desktop.
load texture from web on android
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
public string url = "https://docs.unity3d.com/uploads/Main/ShadowIntro.png";
IEnumerator Start()
{
Texture2D tex;
tex = new Texture2D(4, 4, TextureFormat.PVRTC_RGB2, false);
using (WWW www = new WWW(url))
{
yield return www;
www.LoadImageIntoTexture(tex);
GetComponent<Renderer>().material.mainTexture = tex;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment