从后台加载texture转为sprite

  IEnumerator LoadImage(string path) //图片地址
    {
        var uwr = new UnityWebRequest(path);
        uwr.downloadHandler = new DownloadHandlerTexture();
        yield return uwr.SendWebRequest();
        Texture2D tex = DownloadHandlerTexture.GetContent(uwr);
        Pre.GetComponent().sprite= Sprite.Create(tex, new Rect(0,0,tex.width, tex.height), Vector2.zero, 1f);        
    }

你可能感兴趣的:(unity)