Created
March 9, 2018 03:51
-
-
Save DanMillerDev/b8b86c3503efa904b46ca488de2834b4 to your computer and use it in GitHub Desktop.
load texture from web on android
This file contains hidden or 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
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