Пример #1
0
        public ABLoadScene AddABLoadScene(string url, int version, ABDataType abtype)
        {
            string keyName = url + version.ToString();

            ABLoadScene bl = new ABLoadScene(version, abtype);

            mABLoadScenes[keyName] = bl;

            return(bl);
        }
Пример #2
0
    /// <summary>
    /// 获取指定wwwurl的对象资源
    /// </summary>
    /// <param name="url">用于www加载的路径</param>
    /// <param name="resname">包内的资源名</param>
    /// <param name="type">包内资源名的加载类型</param>
    /// <param name="abtype">加载的路径是MPQ里的还是本地文件的</param>
    /// <returns></returns>
    public static bool GetAB(string url, string resname, System.Type type, ABDataType abtype = ABDataType.Mpq)
    {
        //  如果是声音,强制变成Normal.
        if (typeof(AudioClip) == type)
        {
            abtype = ABDataType.Normal;
        }

        ABLoad mAB = null;

        //Debuger.Log("GetAB " + url);

        do
        {
            //  获取已有
            mAB = mUti.mFactory.Get(url, version);

            //Debuger.Log("mAB " + mAB);

            if (mAB == null)
            {
                break;
            }

            //  获取资源对象
            Object res = mAB.GetObject(resname, type, ShowParticleSys);

            //Debuger.Log("res " + res);

            if (res == null)
            {
                break;
            }

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

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

            return(true);
        } while (true);

        if (mAB == null)
        {
            mAB = mUti.mFactory.Add(url, version, abtype);
        }

        mUti.StartCoroutine(mUti.CallBackSync(mAB, url, resname, type, abtype));

        return(true);
    }
Пример #3
0
    public static bool GetABScene(string url, string resname, System.Type type, ABDataType abtype = ABDataType.Mpq)
    {
#if UNITY_STANDALONE_WIN
        if (url.ToLower().EndsWith(".mp3"))
        {
            Debuger.LogError("ABLoad.Load GetAudioClip Not Supported Mp3! " + url);

            return(false);
        }
#endif

        ABLoadScene mAB = null;

        Debuger.Log("GetABScene " + url);

        do
        {
            //  获取已有
            mAB = mUti.mFactory.GetABLoadScene(url, version);

            Debuger.Log("mAB " + mAB);

            if (mAB == null)
            {
                break;
            }

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

                OnSceneFinishLoading(url, resname, true);
            }

            return(true);
        } while (true);

        if (mAB == null)
        {
            mAB = mUti.mFactory.AddABLoadScene(url, version, abtype);
        }

        mUti.StartCoroutine(mUti.SceneCallBack(mAB, url, resname, abtype));

        return(true);
    }
Пример #4
0
        public ABLoad Add(string url, int version, ABDataType abtype)
        {
            string keyName = url + version.ToString();

            ABLoad bl = null;

            switch (abtype)
            {
                case ABDataType.Normal:
                    bl = new ABLoadFile(version, true);
                    break;
                case ABDataType.Mpq:
                    bl = new ABLoadMpq(version, true);
                    break;
            }
            mABLoads[keyName] = bl;

            return bl;
        }
Пример #5
0
        public ABLoad Add(string url, int version, ABDataType abtype)
        {
            string keyName = url + version.ToString();

            ABLoad bl = null;

            switch (abtype)
            {
            case ABDataType.Normal:
                bl = new ABLoadFile(version, true);
                break;

            case ABDataType.Mpq:
                //bl = new ABLoadMpq(version, true);
                break;
            }
            mABLoads[keyName] = bl;

            return(bl);
        }
Пример #6
0
        public ABLoadScene(int version, ABDataType abtype) 
            : base(version)
        {
            mABDataType = abtype;

            switch (abtype)
            {
                case ABDataType.Mpq:
                    loadAdapter = new ABLoadMpq(version, false);
                    break;
                case ABDataType.Normal:
                    loadAdapter = new ABLoadFile(version,false);
                    break;
            }

            loadAdapter.mDontDestroyOnLoad = true;

            mAutoRelease = false;

            //mDontDestroyOnLoad = true;
        }
Пример #7
0
        public ABLoadScene(int version, ABDataType abtype)
            : base(version)
        {
            mABDataType = abtype;

            switch (abtype)
            {
            case ABDataType.Mpq:
                //loadAdapter = new ABLoadMpq(version, false);
                break;

            case ABDataType.Normal:
                loadAdapter = new ABLoadFile(version, false);
                break;
            }

            loadAdapter.mDontDestroyOnLoad = true;

            mAutoRelease = false;

            //mDontDestroyOnLoad = true;
        }
Пример #8
0
    public IEnumerator SceneCallBack(ABLoadScene mAB, string url, string resname, ABDataType abtype = ABDataType.Mpq)
    {
        Count++;

        string errorcode = string.Empty;

        do
        {
            if (!mAB.Create(url))
            {
                errorcode = "ABLoadScene Create " + url;

                break;
            }

            yield return StartCoroutine(mAB.Waiting());

            Debuger.Log("Waiting End ");

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

                yield return null;
            }

            if (mAB.Error())
            {
                errorcode = mAB.GetErrorMsg();

                break;
            }
            else
            {
                //  返回
                if (OnSceneFinishLoading != null)
                {
                    //Debuger.Log("AssetBundleUti.OnFinishLoading " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString());

                    OnSceneFinishLoading(url, resname, true);
                }

            }

            yield return 1;
        }
        while (false);

        if (OnSceneFinishLoading != null)
        {
            //Debuger.Log("AssetBundleUti.OnFinishLoading " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString());

            curContent = errorcode;

            OnSceneFinishLoading(url, resname, false, errorcode);
        }

        Count--;

        releaseQueue.Enqueue(mAB);

        if (Count <= 0)
        {
            Count = 0;
            releaseAllBundles();
        }

    }
Пример #9
0
    public static bool GetABScene(string url, string resname, System.Type type, ABDataType abtype = ABDataType.Mpq)
    {
#if UNITY_STANDALONE_WIN
        if (url.ToLower().EndsWith(".mp3"))
        {
            Debuger.LogError("ABLoad.Load GetAudioClip Not Supported Mp3! " + url);

            return false;
        }
#endif

        ABLoadScene mAB = null;

        Debuger.Log("GetABScene " + url);

        do
        {
            //  获取已有 
            mAB = mUti.mFactory.GetABLoadScene(url, version);

            Debuger.Log("mAB " + mAB);

            if (mAB == null)
                break;

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

                OnSceneFinishLoading(url, resname, true);

            }

            return true;

        } while (true);

        if (mAB == null)
            mAB = mUti.mFactory.AddABLoadScene(url, version, abtype);

        mUti.StartCoroutine(mUti.SceneCallBack(mAB, url, resname, abtype));

        return true;
    }
Пример #10
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();
        }
    }
Пример #11
0
    /// <summary>
    /// 获取指定wwwurl的对象资源
    /// </summary>
    /// <param name="url">用于www加载的路径</param>
    /// <param name="resname">包内的资源名</param>
    /// <param name="type">包内资源名的加载类型</param>
    /// <param name="abtype">加载的路径是MPQ里的还是本地文件的</param>
    /// <returns></returns>
    public static bool GetAB(string url, string resname, System.Type type, ABDataType abtype = ABDataType.Mpq)
    {
        //  如果是声音,强制变成Normal.
        if (typeof(AudioClip) == type)
            abtype = ABDataType.Normal;

        ABLoad mAB = null;

        //Debuger.Log("GetAB " + url);

        do
        {
            //  获取已有 
            mAB = mUti.mFactory.Get(url, version);

            //Debuger.Log("mAB " + mAB);

            if (mAB == null)
                break;

            //  获取资源对象 
            Object res = mAB.GetObject(resname, type, ShowParticleSys);

            //Debuger.Log("res " + res);

            if (res == null)
                break;

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

                OnFinishLoading(url, resname, type, true);

            }

            return true;

        } while (true);

        if (mAB == null)
            mAB = mUti.mFactory.Add(url, version, abtype);

        mUti.StartCoroutine(mUti.CallBackSync(mAB, url, resname, type, abtype));

        return true;
    }
Пример #12
0
        public ABLoadScene AddABLoadScene(string url, int version, ABDataType abtype)
        {
            string keyName = url + version.ToString();

            ABLoadScene bl = new ABLoadScene(version, abtype);
            mABLoadScenes[keyName] = bl;

            return bl;
        }
Пример #13
0
    public IEnumerator SceneCallBack(ABLoadScene mAB, string url, string resname, ABDataType abtype = ABDataType.Mpq)
    {
        Count++;

        string errorcode = string.Empty;

        do
        {
            if (!mAB.Create(url))
            {
                errorcode = "ABLoadScene Create " + url;

                break;
            }

            yield return(StartCoroutine(mAB.Waiting()));

            Debuger.Log("Waiting End ");

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

                yield return(null);
            }

            if (mAB.Error())
            {
                errorcode = mAB.GetErrorMsg();

                break;
            }
            else
            {
                //  返回
                if (OnSceneFinishLoading != null)
                {
                    //Debuger.Log("AssetBundleUti.OnFinishLoading " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString());

                    OnSceneFinishLoading(url, resname, true);
                }
            }

            yield return(1);
        }while (false);

        if (OnSceneFinishLoading != null)
        {
            //Debuger.Log("AssetBundleUti.OnFinishLoading " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString());

            curContent = errorcode;

            OnSceneFinishLoading(url, resname, false, errorcode);
        }

        Count--;

        releaseQueue.Enqueue(mAB);

        if (Count <= 0)
        {
            Count = 0;
            releaseAllBundles();
        }
    }
Пример #14
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.LoadAssetAsync(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();
        }
    }