Beispiel #1
0
        internal AssetBundleData UF_LoadAssetBundleData(string bundleName, LoadAssetBundleOptions flag)
        {
            try
            {
                bundleName = UF_WrapBundleName(bundleName);
                //检查BUFF中是否存在
                var abd = UF_GetAssetBundleDataFromBuffer(bundleName);

                if (abd != null)
                {
                    return(abd);
                }

                abd = UF_LoadAssetBundleDataFromFile(bundleName, flag);

                if (abd != null)
                {
                    UF_AddBundleDataToBuffer(abd);
                    //检查依赖
                    UF_CheckDependenBundles(bundleName);
                }
                else
                {
                    Debugger.UF_Error(string.Format("AssetBundleData[{0}] Load Failed", bundleName));
                }
                return(abd);
            }
            catch (System.Exception e)
            {
                Debugger.UF_Exception(e);
            }
            return(null);
        }
Beispiel #2
0
        private AssetBundleData UF_LoadAssetBundleDataFromFile(string bundleName, LoadAssetBundleOptions flag)
        {
            AssetBundleData abd = null;

            //审核模式读取Raw中资源,并且需要resKey偏移
            if (GlobalSettings.IsAppCheck && GlobalSettings.IsRawAsset)
            {
                //尝试加载替换资源
                abd = UF_TryGetRebundleAsset(bundleName);
                if (abd != null)
                {
                    return(abd);
                }
                //
                var afi = AssetDataBases.UF_GetAssetInfo(bundleName);
                if (afi == null || string.IsNullOrEmpty(afi.path))
                {
                    Debugger.UF_Error(string.Format("bundleName:[{0}] AssetDataBases.UF_GetAssetInfo failed", bundleName));
                    return(null);
                }
                //需要写入文件偏移
                abd = AssetBundleData.UF_LoadFromStream(bundleName, afi.path, flag, GlobalSettings.EncBKey, GlobalSettings.ResBKey);
            }
            else
            {
                var afi = AssetDataBases.UF_GetAssetInfo(bundleName);
                if (afi == null || string.IsNullOrEmpty(afi.path))
                {
                    Debugger.UF_Error(string.Format("bundleName:[{0}] AssetDataBases.UF_GetAssetInfo failed", bundleName));
                    return(null);
                }
                //abd = AssetBundleData.LoadFromFile(bundleName, afi.path, flag);
                //需要管理Stream随AssetBundle 的释放去释放,否则Strem并不会自己释放导致IO读写错误
                abd = AssetBundleData.UF_LoadFromStream(bundleName, afi.path, flag, GlobalSettings.EncBKey, 0);
            }
            return(abd);
        }
Beispiel #3
0
 public static AssetBundleData UF_LoadFromFile(string bundleName, string path, LoadAssetBundleOptions flag)
 {
     try
     {
         AssetBundle ab = AssetBundle.LoadFromFile(path);
         if (ab != null)
         {
             return(AssetBundleData.UF_Acquire(bundleName, ab, null, flag));
         }
     }
     catch (System.Exception e)
     {
         Debugger.UF_Exception(e);
     }
     return(null);
 }
Beispiel #4
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);
        }
Beispiel #5
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);
        }