Esempio n. 1
0
    public IEnumerator LoadFromURLRoutine(Image mediaObj, string mediaPath, bool resizeToFill)
    {
        var mediaRequest = new WWW(mediaPath);

        yield return(mediaRequest);

        if (string.IsNullOrEmpty(mediaRequest.error))
        {
            mediaObj.sprite = Sprite.Create(mediaRequest.texture, new Rect(0, 0, mediaRequest.texture.width, mediaRequest.texture.height), new Vector2(0.5f, 0.5f));

            if (resizeToFill)
            {
                ResizeImage.ResizeToFill(mediaRequest.texture, mediaObj.rectTransform);
            }
        }

        mediaRequest.Dispose();
    }
Esempio n. 2
0
    public IEnumerator LoadFromURLRoutine(List <Image> mediaObjList, List <string> mediaPathList, bool resizeToFill)
    {
        for (int i = 0; i < mediaPathList.Count; i++)
        {
            var mediaRequest = new WWW(mediaPathList[i]);
            yield return(mediaRequest);

            if (string.IsNullOrEmpty(mediaRequest.error))
            {
                mediaObjList[i].sprite = Sprite.Create(mediaRequest.texture, new Rect(0, 0, mediaRequest.texture.width, mediaRequest.texture.height), new Vector2(0.5f, 0.5f));

                if (resizeToFill)
                {
                    ResizeImage.ResizeToFill(mediaRequest.texture, mediaObjList[i].rectTransform);
                }
            }

            mediaRequest.Dispose();
        }
    }