private IEnumerator GetImage(string url, Image fileImage)
    {
        UnityWebRequest WebRequest = new UnityWebRequest(url);
        DownloadHandlerTexture Download = new DownloadHandlerTexture();
        WebRequest.downloadHandler = Download;
        yield return WebRequest.SendWebRequest();

        if (WebRequest.downloadHandler.isDone)
        {
            if (!fileImage)
            {
                if (Application.platform == RuntimePlatform.WindowsEditor ||
                    Application.platform == RuntimePlatform.WindowsPlayer)
                    File.WriteAllBytes(Application.streamingAssetsPath + "/HeadPicture.png", Download.data);
                else if (Application.platform == RuntimePlatform.Android)
                    File.WriteAllBytes(Application.persistentDataPath + "/HeadPicture.png", Download.data);

                SetHeadPictureComponent();
            }
            else
            {
                Rect spriteRect = new Rect(0, 0, Download.texture.width, Download.texture.height);
                Sprite sprite = Sprite.Create(Download.texture, spriteRect, Vector2.zero);
                fileImage.sprite = sprite;
            }
        }
    }

相关文章:

  • 2021-12-25
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-04-23
  • 2021-10-20
猜你喜欢
  • 2021-07-12
  • 2022-12-23
  • 2021-06-30
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案