Exemplo n.º 1
0
        public override void Dispose()
        {
            Unload();

            {
                foreach (ABLoad e in mAbLoadObject)
                {
                    ABLoad abloadTmp = (ABLoad)e;

                    switch (mABDataType)
                    {
                    case ABDataType.Mpq:
                        //((ABLoadMpq)abloadTmp).Dispose();
                        break;

                    case ABDataType.Normal:
                        ((ABLoadFile)abloadTmp).Dispose();
                        break;
                    }
                    abloadTmp = null;
                }
                mAbLoadObject.Clear();
            }

            {
                if (loadAdapter != null)
                {
                    loadAdapter.Dispose();
                }

                loadAdapter = null;
            }

            base.Dispose();
        }
Exemplo n.º 2
0
        public void Close()
        {
            foreach (ABLoad e in allbundleloads.Values)
            {
                ABLoad ab = (ABLoad)e;
                ab.Dispose();
                ab = null;
            }

            allbundleloads.Clear();
        }
Exemplo n.º 3
0
    public IEnumerator CallBackSync(ABLoad mAB, string url, string resname, System.Type type, ABDataType abtype)
    {
        //Debuger.Log("AssetBundleUti.CallBack " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString());
        
        Count++;

        callbackerror = string.Empty;
        bCallback = true;

        do
        {
            if (!mAB.Create(url))
            {   
                callbackerror = "ABLoad Create Error " + url;
                bCallback = false;

                break;
            }

            yield return StartCoroutine(mAB.Waiting());
		
            //Debuger.Log("Waiting End ");

            while (true)
            {
                if (mAB.IsWWW())
                    break;

                yield return null;
            }
		
            //Debuger.Log("Error " + mAB.Error());

		    if (mAB.Error())
		    {
                //Debuger.LogError(mAB.GetErrorMsg());
                callbackerror = mAB.GetErrorMsg();
                bCallback = false;

                break;
		    }
		    else
		    {
	            if (typeof(AudioClip) == type)
	            {
	                AudioClip ac = mAB.Load(resname);
	
                    //Debuger.Log(resname + " " + ac.length + " " + ac.samples + " " + ac.isReadyToPlay + " " + ac.channels);
                    //Debuger.Log(ac.isReadyToPlay);
	
	                if (ac != null)
	                {
	                    while (true)
	                    {
	                        if (ac.isReadyToPlay)
	                            break;

                            yield return null;
                        }

                        ac.name = resname;
	                    mAB.Pair(resname, ac, type);
	
	                    //  返回
                        if (OnFinishLoading != null)
                        {
                            //Debuger.Log("AssetBundleUti.OnFinishLoading " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString());

                            OnFinishLoading(url, resname, type, true);
                        }
	
	                }
	                else
	                {
	                    Debuger.LogError("Load " + resname + " in " + url);

                        callbackerror = mAB.GetErrorMsg();
                        bCallback = false;

                        break;
	                }
	            }
	            else
	            {
                    AssetBundle ab = mAB.GetAb();
                    if (ab == null)
                    {
                        callbackerror = "AssetBundle == null";
                        bCallback = false;

                        break;
                    }

                    AssetBundleRequest request = ab.LoadAsync(resname, type);
                    if (request == null)
                    {
                        callbackerror = "LoadAsync AssetBundleRequest == null";
                        bCallback = false;

                        break;
                    }

	                while (true)
	                {
	                    if (request.isDone)
	                        break;

                        yield return null;
                    }

                    mAB.Pair(resname, request.asset, type);
	
	                //  返回
                    if (OnFinishLoading == null)
                    {
                        //Debuger.Log("AssetBundleUti.OnFinishLoading " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString());
                        callbackerror = "OnFinishLoading == null";
                        bCallback = false;

                        break;
                    }

                    OnFinishLoading(url, resname, type, true);
	            }
		    }

        }
        while (false);

        if (!bCallback)
        {
            Debuger.LogError("Error " + mAB.Error() + " callbackerror: " + callbackerror);

            MessageBox(callbackerror + " \r\n " + OnFinishLoading.ToString());

            OnFinishLoading(url, resname, type, false, callbackerror);

            if (mAB != null)
            {
                mAB.Dispose();
                mAB = null;
            }
        }
        else
        {
            releaseQueue.Enqueue(mAB);
        }

        Count--;

        if (Count <= 0)
        {
            Count = 0;
            releaseAllBundles();
        }
    }
Exemplo n.º 4
0
        public void CleanABByScene()
        {
            ////foreach (KeyValuePair<string, ABLoad> e in mABLoads)
            ////{
            ////    ABLoad bl = (ABLoad)mABLoads[e.Key];
            ////    if (!bl.IsDontDestroyOnLoad())
            ////    {
            ////        bl.Dispose();
            ////        bl = null;

            ////        mABLoads.Remove(e.Key);
            ////    }
            ////}
            ////mABLoads.Clear();
            ////mABLoads = null;


            {
                List <string> listABLoadOrders = new List <string>(mABLoads.Keys);
                List <ABLoad> listABLoad       = new List <ABLoad>(mABLoads.Values);
                for (int i = 0; i < listABLoad.Count; i++)
                {
                    ABLoad bl = (ABLoad)listABLoad[i];
                    if (!bl.IsDontDestroyOnLoad())
                    {
                        bl.Dispose();
                        bl = null;
                    }

                    //  根据序号去删除.
                    mABLoads.Remove(listABLoadOrders[i]);
                }
                listABLoadOrders.Clear();
                listABLoad.Clear();
                listABLoadOrders = null;
                listABLoad       = null;
            }

            {
                List <string>      listABLoadOrders = new List <string>(mABLoadScenes.Keys);
                List <ABLoadScene> listABLoad       = new List <ABLoadScene>(mABLoadScenes.Values);
                for (int i = 0; i < listABLoad.Count; i++)
                {
                    ABLoadScene bl = (ABLoadScene)listABLoad[i];
                    if (!bl.IsDontDestroyOnLoad())
                    {
                        bl.Dispose();
                        bl = null;
                    }

                    //  根据序号去删除.
                    mABLoadScenes.Remove(listABLoadOrders[i]);
                }
                listABLoadOrders.Clear();
                listABLoad.Clear();
                listABLoadOrders = null;
                listABLoad       = null;
            }

            ////foreach (KeyValuePair<string, ABLoadScene> e in mABLoadScenes)
            ////{
            ////    ABLoadScene bl = (ABLoadScene)mABLoadScenes[e.Key];
            ////    if (!bl.IsDontDestroyOnLoad())
            ////    {
            ////        bl.Dispose();
            ////        bl = null;

            ////        mABLoadScenes.Remove(e.Key);
            ////    }

            ////}
            ////mABLoadScenes.Clear();
            ////mABLoadScenes = null;
        }