Пример #1
0
        public static AssetBundleData UF_LoadFromStream(string bundleName, string path, LoadAssetBundleOptions flag, int byteKey = 0, int byteofs = 0)
        {
            AssetBundleStream abstream = null;

            try
            {
                if (!File.Exists(path))
                {
                    Debugger.UF_Error(string.Format("File[{0}] not exist ,LoadFromStream failed", path));
                    return(null);
                }
                abstream = new AssetBundleStream(path, FileMode.Open, FileAccess.Read, byteKey, byteofs);
                AssetBundle ab = AssetBundle.LoadFromStream(abstream);
                if (ab != null)
                {
                    return(AssetBundleData.UF_Acquire(bundleName, ab, abstream, flag));
                }
            }
            catch (System.Exception e)
            {
                Debugger.UF_Exception(e);
            }
            if (abstream != null)
            {
                abstream.Close();
            }
            abstream.Dispose();
            return(null);
        }
Пример #2
0
        //获取请求
        static AssetBundleData UF_Acquire(string bundleName, AssetBundle ab, AssetBundleStream stream, LoadAssetBundleOptions flag)
        {
            AssetBundleData ret = null;

            lock (s_DataPool)
            {
                ret = s_DataPool.Pop();
                if (ret == null)
                {
                    ret = new AssetBundleData();
                }
            }
            ret.name        = bundleName;
            ret.assetbundle = ab;
            ret.stream      = stream;
            ret.flag        = flag;
            ret.tick        = 0;
            ret.isDispose   = false;
            return(ret);
        }