I’m using the following script to download textures from a URL and apply them to GameObjects, the script is on each GameObject that requires a texture:
public class LoadTex : MonoBehaviour {
public string url;
IEnumerator Start()
{
WWW www = new WWW(url);
yield return (www);
Renderer renderer = GetComponent<Renderer> ();
renderer.material.mainTexture = www.texture;
}
}
This works great on GameObjects that are active on start up but when I turn on a GameObject during runtime, it shows no texture.
Why is this and how do I fix the issue?