예제 #1
0
        public override bool LoadSync()
        {
            if (!CheckLoadAble())
            {
                return(false);
            }

            resState = eResState.kLoading;

            //TimeDebugger timer = ResMgr.S.timeDebugger;

            string url = ProjectPathConfig.AssetBundleName2Url(m_Name);

            //timer.Begin("LoadSync AssetBundle:" + m_Name);
            AssetBundle bundle = AssetBundle.LoadFromFile(url);

            //timer.End();

            m_UnloadFlag = true;

            if (bundle == null)
            {
                Log.e("Failed Load AssetBundle:" + m_Name);
                OnResLoadFaild();
                return(false);
            }

            assetBundle = bundle;
            resState    = eResState.kReady;
            ++s_ActiveCount;
            //Log.i(string.Format("Load AssetBundle Success.ID:{0}, Name:{1}", bundle.GetInstanceID(), bundle.name));

            //timer.Dump(-1);
            return(true);
        }
예제 #2
0
        public override IEnumerator StartIEnumeratorTask(Action finishCallback)
        {
            //开启的时候已经结束了
            if (refCount <= 0)
            {
                OnResLoadFaild();
                finishCallback();
                yield break;
            }

            string url = ProjectPathConfig.AssetBundleName2Url(m_Name);

            AssetBundleCreateRequest abcR = AssetBundle.LoadFromFileAsync(url);

            m_AssetBundleCreateRequest = abcR;
            yield return(abcR);

            m_AssetBundleCreateRequest = null;

            if (!abcR.isDone)
            {
                Log.e("AssetBundleCreateRequest Not Done! Path:" + m_Name);
                OnResLoadFaild();
                finishCallback();
                yield break;
            }

            assetBundle = abcR.assetBundle;

            resState = eResState.kReady;
            ++s_ActiveCount;

            finishCallback();
        }
예제 #3
0
        public string[] GetAllDependenciesByUrl(string url)
        {
            string abName = ProjectPathConfig.AssetBundleUrl2Name(url);

            string[] depends = null;

            for (int i = m_ActiveAssetDataPackages.Count - 1; i >= 0; --i)
            {
                if (!m_ActiveAssetDataPackages[i].GetAssetBundleDepends(abName, out depends))
                {
                    continue;
                }

                return(depends);
            }

            return(null);
        }
예제 #4
0
        private void ProcessNewInstall()
        {
            bool isNewInstall = CheckIsNewInstall();

            Log.i("Check Is New Install:" + isNewInstall);

            if (isNewInstall)
            {
                //对比外部文件
                List <string> outResult = new List <string>();
                FilePath.GetFileInFolder(FilePath.persistentDataPath4Res, ProjectPathConfig.abConfigfileName, outResult);

                AssetDataTable exterTable = new AssetDataTable();
                for (int i = 0; i < outResult.Count; ++i)
                {
                    exterTable.LoadPackageFromFile(outResult[i]);
                }

                //生成差异文件列表:
                List <ABUnit> needDeleteList = ABUnitHelper.CalculateLateList(exterTable, AssetDataTable.S, false);

                for (int i = 0; i < needDeleteList.Count; ++i)
                {
                    ABUnit unit          = needDeleteList[i];
                    string exterFilePath = ProjectPathConfig.AssetBundleName2ExterUrl(unit.abName);
                    if (File.Exists(exterFilePath))
                    {
                        File.Delete(exterFilePath);
                    }
                }

                var packages = AssetDataTable.S.allAssetDataPackages;
                if (packages.Count > 0)
                {
                    var package = packages[0];
                    PlayerPrefs.SetString(INNER_RES_PACKAGE, package.key);
                    PlayerPrefs.SetInt(INNER_RES_BUILDTIME, (int)package.buildTime);
                    PlayerPrefs.Save();
                }
            }
        }
예제 #5
0
        private static ProjectPathConfig LoadInstance()
        {
            UnityEngine.Object obj = Resources.Load(ResourcesPath2Path(PROJECT_CONFIG_PATH));

            if (obj == null)
            {
                Log.w("Not Find Project Config File, Try Load Default Config.");

                obj = Resources.Load(ResourcesPath2Path(DEFAULT_PROJECT_CONFIG_PATH));

                if (obj == null)
                {
                    Log.e("Not Find Default Project Config File!");
                    return(null);
                }
            }

            //Log.i("Success Load Project Config.");

            s_Instance = obj as ProjectPathConfig;

            return(s_Instance);
        }
예제 #6
0
 public static void Reset()
 {
     Resources.UnloadAsset(s_Instance);
     s_Instance = null;
 }