//-------------------------------------------------------------------------
    public void update(float tm)
    {
        foreach (var i in MapAssetBundleCreateRequest)
        {
            AssetBundleCreateRequest assetbundle_createrequest = i.Value;
            if (assetbundle_createrequest != null)
            {
                if (assetbundle_createrequest.isDone)
                {
                    MapAssetBundle[i.Key] = i.Value.assetBundle;
                }
            }
        }

        foreach (var i in MapAssetBundle)
        {
            MapAssetBundleCreateRequest.Remove(i.Key);

            Action <string, AssetBundle> ticketandcallback = null;
            if (MapLoaderTicketAndCallBack.TryGetValue(i.Key, out ticketandcallback))
            {
                ticketandcallback(i.Key, i.Value);
                MapLoaderTicketAndCallBack.Remove(i.Key);
            }
        }
        MapAssetBundle.Clear();
    }
Ejemplo n.º 2
0
    //-------------------------------------------------------------------------
    public void asyncLoadBundle(string bundle_path, _eAsyncAssetLoadType loader_type, Action <string, AssetBundle> loaded_action)
    {
        AssetBundle asset_bundle = null;

        if (MapAssetBundle.TryGetValue(bundle_path, out asset_bundle))
        {
            loaded_action(bundle_path, asset_bundle);
            return;
        }
        else
        {
            Action <string, AssetBundle> action = null;
            if (!MapLoadAssetBundleCallBack.TryGetValue(bundle_path, out action))
            {
                action = loaded_action;
            }
            else
            {
                action += loaded_action;
            }
        }

        if (loader_type == _eAsyncAssetLoadType.LocalBundle)
        {
            AsyncAssetLoaderMgr.LocalBundleAsyncLoader.getAssetBundle(bundle_path, _loadAssetBundleCallBack);
        }
        else if (loader_type == _eAsyncAssetLoadType.WWWBundle)
        {
            AsyncAssetLoaderMgr.WWWBundleAsyncLoader.getAssetBundle(bundle_path, _loadAssetBundleCallBack);
        }

        //return null;
    }
Ejemplo n.º 3
0
    //-------------------------------------------------------------------------
    public void releaseAssetBundle()
    {
        foreach (var i in MapAssetBundle)
        {
            if (i.Value != null)
            {
                i.Value.Unload(false);
            }
        }

        MapAssetBundle.Clear();
    }
Ejemplo n.º 4
0
        //---------------------------------------------------------------------
        IEnumerator _localLoadTextureFromAbAsync(string url, string name, Action <Texture> cb)
        {
            MapAssetBundle.TryGetValue(url, out AssetBundle ab);

            // 判定是否已加载Ab
            if (ab == null)
            {
                // 判定是否正在加载Ab
                bool b = SetAssetBundleLoading.Contains(url);

                if (b)
                {
                    while (true)
                    {
                        yield return(1);// 等1帧

                        if (!SetAssetBundleLoading.Contains(url))
                        {
                            ab = MapAssetBundle[url];
                            break;
                        }
                    }
                }
                else
                {
                    SetAssetBundleLoading.Add(url);

                    AssetBundleCreateRequest abcr = AssetBundle.LoadFromFileAsync(url);
                    yield return(abcr);

                    ab = abcr.assetBundle;
                    MapAssetBundle[url] = ab;

                    SetAssetBundleLoading.Remove(url);
                }
            }

            string s = url + name;

            MapTexture2D.TryGetValue(s, out Texture2D t);
            if (t == null)
            {
                t = ab.LoadAsset <Texture2D>(name);
                MapTexture2D[s] = t;
            }

            if (cb != null)
            {
                cb.Invoke(t);
            }
        }
Ejemplo n.º 5
0
    //-------------------------------------------------------------------------
    public LoaderTicket asyncLoadLocalBundle(List <string> list_bundle_path, _eAsyncAssetLoadType loader_type,
                                             Action <List <AssetBundle> > loaded_action)
    {
        LoaderTicket loader_ticket = new LoaderTicket();
        Dictionary <string, AssetBundle> map_needloadab = new Dictionary <string, AssetBundle>();

        loader_ticket.MapNeedLoadAssetBundle = map_needloadab;
        Dictionary <string, AssetBundle> map_loadedab = new Dictionary <string, AssetBundle>();

        loader_ticket.MapLoadedAssetBundle = map_loadedab;
        foreach (var i in list_bundle_path)
        {
            AssetBundle asset_bundle = null;
            if (MapAssetBundle.TryGetValue(i, out asset_bundle))
            {
                map_loadedab[i] = asset_bundle;
            }
            else
            {
                map_needloadab[i] = null;
                if (loader_type == _eAsyncAssetLoadType.LocalBundle)
                {
                    AsyncAssetLoaderMgr.LocalBundleAsyncLoader.getAssetBundle(i, _loadAssetBundleCallBack);
                }
                else if (loader_type == _eAsyncAssetLoadType.WWWBundle)
                {
                    AsyncAssetLoaderMgr.WWWBundleAsyncLoader.getAssetBundle(i, _loadAssetBundleCallBack);
                }
            }
        }

        if (loader_ticket.MapLoadedAssetBundle.Count == list_bundle_path.Count)
        {
            List <AssetBundle> list_bundle = new List <AssetBundle>();
            foreach (var i in loader_ticket.MapLoadedAssetBundle)
            {
                list_bundle.Add(i.Value);
            }
            loaded_action(list_bundle);
        }
        else
        {
            MapLoaderTicket[loader_ticket] = loaded_action;
        }

        return(loader_ticket);
    }
Ejemplo n.º 6
0
 //-------------------------------------------------------------------------
 public void Close()
 {
     MapAssetBundle.Clear();
     MapAssetBundleCreateRequest.Clear();
     MapLoaderTicketAndCallBack.Clear();
 }