예제 #1
0
    public void load(string DownloadPath, string FilePath, Action <AssetBundle, string> Loaded)
    {
        Action <WWW> callback = (www) =>
        {
            Exception _err = null;
            SelectABName = FilterABName(DownloadPath);
            try
            {
                if (www.error == null && www.bytes != null)
                {
                    NeedParserAB = www.assetBundle;
                    Loaded(NeedParserAB, SelectABName);
                    NeedParserAB.Unload(false);    //必须卸载掉,否则WWW再次加载会报错,参数unloadAllLoadedObjects
                    Resources.UnloadUnusedAssets();
                }
                else
                {
                    _err = new Exception();
                }
            }
            catch (Exception error)
            {
                _err = error;
            }
            if (_err != null)
            {
                Debug.Log("<color=red>download " + SelectABName + " error </color>");
            }
        };
        DownLoad task = DownLoad.New(DownloadPath, callback);

        task.StartDownLoad();
    }