- Home /
Answer by Cherno · May 01, 2016 at 08:01 PM
Try the WWW class. The Scripting API has an example that is an almost perfect match for your needs.
I tried this, but I get this:
$$anonymous$$eaning that the sprite hasn't actually changed
untitled.png
(20.3 kB)
Have you looked at the variables of the WWW class, specifically WWW.texture?
I have come up with this, but still the same problem as in the screenshot. No errors or anything.
public string url;
public Texture2D sprites;
IEnumerator Start()
{
Debug.Log(PlayerPrefs.GetString("profilepicurl"));
url = PlayerPrefs.GetString("profilepicurl");
WWW www = new WWW(url);
yield return www;
sprites = www.texture;
Rect rec = new Rect(0, 0, sprites.width, sprites.height);
Sprite hello = Sprite.Create(sprites, rec, new Vector2(0, 0), 1);
GameObject.Find("profilepic").GetComponent<SpriteRenderer>().sprite = hello;
}
lol.png
(14.1 kB)