Example #1
0
    //www load
    IEnumerator wwwLoad()
    {
        //Debug.Log("加载资源" + url);
        status = E_LoadStatus.Loading;
        if (string.IsNullOrEmpty(url))
        {
            status = E_LoadStatus.Fail;
            yield break;
        }
        //是否已经存在ab
        if (AssetMgr.isHave(url))
        {
            for (int i = 0; i < handlerLst.Count; i++)
            {
                handlerLst[i].Invoke(url, true, AssetMgr.getBundle(url));
            }
            status = E_LoadStatus.Finish;
            yield break;
        }

        //加载资源
        AssetBundleCreateRequest abReq = AssetBundle.LoadFromFileAsync(Path.Combine(Application.dataPath, "Res/AssetBundle/" + url + ".assetbundle"));

        do
        {
            if (abReq.assetBundle == null)
            {
                status = E_LoadStatus.Fail;
                yield break;
            }
            yield return(new WaitForEndOfFrame());
        } while (!abReq.isDone);
        AssetMgr.addBundle(url, abReq.assetBundle);
        for (int i = 0; i < handlerLst.Count; i++)
        {
            handlerLst[i].Invoke(url, true, AssetMgr.getBundle(url));
        }
        status = E_LoadStatus.Finish;
    }