In unity3d, I am using WWW class to download a texture from link, then I am creating a Sprite with the obtained texture and I am displaying it on the screen. This is working just fine in Unity Editor, but when I run it in the browser as HTML5 instead of displaying my Sprite, there is a red question mark. Why?
This is my C# code:
GameObject myImage;
Sprite neededSprite;
IEnumerator Start () {
WWW getMyImage= new WWW("http://ift.tt/2if4nsw");
myImage = GameObject.Find("myImage");
yield return getMyImage;
Texture2D rawImage = getMyImage.texture;
neededSprite = Sprite.Create(rawImage, new Rect(0.0f, 0.0f, rawImage.width, rawImage.height), new Vector2(0.5f, 0.5f), 100.0f);
myImage.GetComponent<Image>().sprite = neededSprite;
}
Aucun commentaire:
Enregistrer un commentaire