Hello, I’m relatively new to Unity, and I’m having some trouble assigning an image loaded from a path through WWW to an image in my scene. After debugging, it seems the image is loaded correctly into the Texture2D (width of the image is the correct one), but it won’t assign it to the desired image.
This is the code:
using UnityEngine;
using UnityEngine.UI;
public class Android_TV : MonoBehaviour {
(...)
public Image photo;
(...)
private IEnumerator LoadImageOnViewer(string path){
WWW data = new WWW ("file://C:\\Users\\User\\Desktop\\Jack\\randomdog.jpg");
yield return data.isDone;
Texture2D tex = new Texture2D (4, 4);
Debug.Log ("data.error: " + data.error);
tex = data.texture;
Debug.Log ("tex width: " + tex.width);
Debug.Log ("data width: " + data.texture.width);
photo.material.mainTexture = tex;
}
}