Example #1
0
    /// <summary>
    /// 协程加载
    /// </summary>
    /// <returns></returns>
    public IEnumerator CommonLoad()
    {
        commonLoader = new WWW(commonBundlePath);

        while (!commonLoader.isDone)
        {
            commonResLoaderProcess = commonLoader.progress;

            if (LoaderProgressing != null)
            {
                LoaderProgressing(bundleName, commonResLoaderProcess);
            }
            yield return(commonLoader.progress);
        }

        if (commonResLoaderProcess >= 1.0f)//表示已经加载完成
        {
            if (LoaderProgressing != null)
            {
                LoaderProgressing(bundleName, commonResLoaderProcess);
            }
            if (LoadFinished != null)
            {
                LoadFinished(bundleName);
            }
            abResloader = new ABResLoader(commonLoader.assetBundle);
        }
        else
        {
            Debug.LogError("load bundle error == " + bundleName);
        }
        commonLoader = null;
    }
Example #2
0
 //释放资源
 public void Dispose()
 {
     if (resLoader != null)
     {
         resLoader.Dispose();
         resLoader = null;
     }
 }
Example #3
0
    public ABLoader(LoaderProgrecess lp, LoadFinish lf)
    {
        commonBundlePath = "";
        bundleName       = "";

        commonResLoaderProcess = 0;

        LoaderProgressing = lp;
        LoadFinished      = lf;
        abResloader       = null;
    }
Example #4
0
    public IEnumerator IELoadAB()
    {
        progress = 0;
        Debug.Log("bundlePath = " + bundlePath);
        www = new WWW(bundlePath);
        // Android 平台替换为   AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(bundlePath);
        //  LoadFromFileAsync 不需要 前缀 File://   加载 Manifest 也要替换
        while (!www.isDone)
        {
            progress = www.progress;
            if (loadProgressHandler != null)
            {
                loadProgressHandler(bundleName, progress);
            }
            yield return(progress);

            progress = www.progress;
        }
        if (progress >= 1.0f)
        {
            resLoader = new ABResLoader(www.assetBundle);
            if (loadProgressHandler != null)
            {
                loadProgressHandler(bundleName, progress);
            }
            if (loadFinishHandler != null)
            {
                loadFinishHandler(bundleName);
            }
        }
        else
        {
            Debug.Log(" AssetBundle Load Error  BundleName = " + bundleName);
        }
        www = null;
    }