public void compareAssetBundleInfo(string oldfilename, string newContent) { AssetBundleInfoData old = new AssetBundleInfoData(); if(!old.ReadAssetBundleInfoFile (oldfilename)) { Debug.LogWarning( "recreate empty assetinfo.txt" ); recreatEmptyAssetinfo(oldfilename); old.ReadAssetBundleInfoFile (oldfilename); } ReadAssetBundleInfo(newContent); foreach(KeyValuePair<string, AssetBundleInfo> pair in AssetBundleInfos){ pair.Value.isNew = IsNewBundle(pair.Key, old); } }
public static void BuildAssetBundles(BuildTarget platform, string infoPath, string objectPath, bool forceBuildAll, AssetBundleInfoData newData, AssetBundleInfoData oldData ) { newData.ClearData(); oldData.ClearData(); //read Asset bundle info file oldData.ReadAssetBundleInfoFile( infoPath ); //gathering all build objects GetbuildObjects(objectPath, newData); //update assetbundle version AssetBundleInfoData.AssetBundleInfo[] AssetBundleInfoForBuild = null; if(forceBuildAll) AssetBundleInfoForBuild = newData.UpdateAll(oldData); else AssetBundleInfoForBuild = newData.UpdateVersion(oldData); //for each updated data, build assetbundle foreach( AssetBundleInfoData.AssetBundleInfo info in AssetBundleInfoForBuild ){ List<Object> objects = new List<Object>(); foreach(string s in info.objs){ objects.Add(newData.AssetObjectInfos[s].obj); } BuildPipeline.BuildAssetBundle(objects[0], objects.ToArray(), infoPath + "/" + info.Name + ".unity3d", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, platform); } //remember the old Assetbundles foreach(KeyValuePair<string, AssetBundleInfoData.AssetBundleInfo> pair in oldData.AssetBundleInfos){ if(!newData.AssetBundleInfos.ContainsKey(pair.Key)){ newData.AssetBundleInfos.Add(pair.Key, pair.Value); foreach(string s in pair.Value.objs){ if(!newData.AssetObjectInfos.ContainsKey(s)){ newData.AssetObjectInfos.Add( s, oldData.AssetObjectInfos[s] ); } } } } //write info file newData.WriteAssetBundleInfo(infoPath); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }