今天项目中遇到一个必须使用StreamingAssets这个目录,而这个目录里面必须使用www加载界面上的资源,自己就总结下,方便下次忘记时可以翻看

private IEnumerator SetLoadingBg()
    {
        string[] bgName = YFSDKManager.Instance.GetChannelImageDate ().GetLoadingArray();
        string path = AppConst.PathURL + "ChannelImage/" +  bgName[Random.Range(0,bgName.Length)];
        WWW www = new WWW(path);
        yield return www;
        if (www.bytes == null) {
            Debug.Log ("请求数据失败");
        }
        if(string.IsNullOrEmpty(www.error))
        {
            ShowBG (www.texture);
        }
    }

public void ShowBG(UnityEngine.Texture tex)
    {
        BG.mainTexture = tex;
    }

这样就可以完美的加载资源啦

 

相关文章:

  • 2021-12-14
  • 2021-07-31
  • 2022-01-07
  • 2021-06-02
  • 2021-11-20
  • 2021-09-11
  • 2021-09-11
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2021-03-31
  • 2021-11-19
  • 2021-06-02
  • 2021-06-25
  • 2022-12-23
相关资源
相似解决方案