UnityWebRequest 本地加载图片

string filePath = Application.streamingAssetsPath + "/证书/a4证书"+ str+".png";
print(filePath);


IEnumerator GetTexture(string url) { UnityWebRequest uwr = UnityWebRequest.Get(url); DownloadHandlerTexture downloadTexture = new DownloadHandlerTexture(true); uwr.downloadHandler = downloadTexture; yield return uwr.SendWebRequest(); if (uwr.isNetworkError || uwr.isHttpError) { print(uwr.error); } else { Texture2D t = downloadTexture.texture; showPic.sprite = Sprite.Create(t, new Rect(0, 0, t.width, t.height), Vector2.one); } }

 

posted on 2022-03-28 13:46  zqiang0803  阅读(776)  评论(0编辑  收藏  举报

导航