public static void BuildAssetBuindles(BuildTarget buildTargetGroup, int version) { List <AssetBundleBuild> buildsList = new List <AssetBundleBuild>(); foreach (var keyValue in m_abbuildDic) { buildsList.Add(keyValue.Value.GetBundleBuild()); } BuildAssetBundleOptions m_options = BuildAssetBundleOptions.DeterministicAssetBundle | BuildAssetBundleOptions.ChunkBasedCompression; var assetBundleManifest = BuildPipeline.BuildAssetBundles(PreOutPath(buildTargetGroup), buildsList.ToArray(), m_options, buildTargetGroup); ABDesc structs = new ABDesc(); AddResrouceToAbDataStruct(assetBundleManifest, structs); m_currentCache.newVersion = m_curVersion; //1存储ResourceManager的描述文件, SaveABDataFile(structs, buildTargetGroup); //2将相应的ab拷贝到对应的文件夹中 CopyABToUpdateForlder(buildTargetGroup); m_currentCache.assetList.Clear(); foreach (var keyvalue in m_dependsDic) { m_currentCache.assetList.Add(keyvalue.Value.ToCacheData()); } ABAssetDataUtil.SaveAssetCache(buildTargetGroup, m_currentCache); }
public static void LoadAndVerions(BuildTarget buildTargetGroup, bool isUpdate = false, int version = 10000) { m_isUpdateShader = false; m_curVersion = version; if (isUpdate) { m_currentCache = ABAssetDataUtil.ReloadCache(buildTargetGroup); if (m_curVersion <= m_currentCache.firstVersion || m_curVersion <= m_currentCache.newVersion) { m_curVersion = m_currentCache.newVersion + 1; } for (int i = 0; i < m_currentCache.assetList.Count; i++) { if (!m_oldDic.ContainsKey(m_currentCache.assetList[i].filePath)) { m_oldDic.Add(m_currentCache.assetList[i].filePath, m_currentCache.assetList[i]); if (!m_abbuildDic.ContainsKey(m_currentCache.assetList[i].bundleId)) { ABBundleInfo buildInfo = new ABBundleInfo(); buildInfo.bundleId = m_currentCache.assetList[i].bundleId; buildInfo.firstVersion = m_currentCache.firstVersion; m_abbuildDic.Add(buildInfo.bundleId, buildInfo); } } } } else { m_currentCache = new ABAssetDataList(); m_currentCache.firstVersion = m_curVersion; } }