void Update() { if (lastTimeSelection != LastSelection()) { lastTimeSelection = LastSelection(); BundleEditorDrawer.ShowBundle(BundleManager.GetBundleData(lastTimeSelection)); } if (m_EditWaitBundle != "" && m_EditWaitStartTime > 0) { // See if we can start edit if (EditorApplication.timeSinceStartup - m_EditWaitStartTime > 0.6) { StartEditBundleName(m_EditWaitBundle); } } if (BMDataAccessor.ShouldSaveBundleData) { BMDataAccessor.ShouldSaveBundleData = false; BMDataAccessor.SaveBundleData(); } if (BMDataAccessor.ShouldSaveBundleStates) { BMDataAccessor.ShouldSaveBundleStates = false; BMDataAccessor.SaveBundleBuildeStates(); } }
/** * Add a path to bundle's include list. * @param path The path must be a path under Asset. Can be path of diretory or file. * @param bundleName The bundle's name. */ public static void AddPathToBundle(string path, string bundleName) { BundleData bundle = GetBundleData(bundleName); //������ӵĴ��� if (bundle.bundleRelativePath == "" || bundle == null) { bundle.bundleRelativePath = path.Substring(0, path.LastIndexOf("/")); } //������ӵĴ��� if (IsNameDuplicatedAsset(bundle, path)) { Debug.LogWarning("Name of new add asset will be duplicate with asset in bundle " + bundleName + ". This may cause problem when you trying to load them."); } string guid = AssetDatabase.AssetPathToGUID(path); bundle.includeGUIDs.Add(guid); AddIncludeRef(guid, bundle); RefreshBundleDependencies(bundle); UpdateBundleChangeTime(bundle.name); BMDataAccessor.SaveBundleData(); }
public static void DrawInspector() { if (currentBundle == null) { GUILayout.FlexibleSpace(); GUILayout.Label("Select bundle to check its content."); GUILayout.FlexibleSpace(); return; } m_ScrollViewPosition = EditorGUILayout.BeginScrollView(m_ScrollViewPosition); { // Bundle type and version BundleBuildState buildStates = BundleManager.GetBuildStateOfBundle(currentBundle.name); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(currentBundle.sceneBundle ? "Scene bundle" : "Asset bundle", BMGUIStyles.GetStyle("BoldLabel")); GUILayout.FlexibleSpace(); GUILayout.Label("Version " + buildStates.version, BMGUIStyles.GetStyle("BoldLabel")); } EditorGUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { string sizeStr = "Build Size " + (buildStates.size == -1 ? "Unkown" : Mathf.CeilToInt(buildStates.size / 1024f) + " KB"); GUILayout.Label(sizeStr, BMGUIStyles.GetStyle("BoldLabel")); GUILayout.FlexibleSpace(); GUILayout.Label("Priority", EditorStyles.boldLabel); int opriority = currentBundle.priority; currentBundle.priority = EditorGUILayout.Popup(currentBundle.priority, new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, GUILayout.MaxWidth(40)); if (opriority != currentBundle.priority) { BMDataAccessor.SaveBundleData(); } } GUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUILayout.BeginVertical(BMGUIStyles.GetStyle("Wizard Box")); { GUI_Inlcudes(); GUI_DependencyList(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh") && currentBundle != null) { BundleManager.RefreshBundleDependencies(currentBundle); BMDataAccessor.SaveBundleData(); } } GUILayout.EndHorizontal(); }
static void OnBuildTargetChanged() { if (BuildConfiger.UseEditorTarget) { BuildConfiger.UnityBuildTarget = EditorUserBuildSettings.activeBuildTarget; BMDataAccessor.SaveUrls(); } }
//remove all bundle static public void RemoveAllBundles() { List <string> allBundleName = new List <string>(); foreach (var bundleName in getInstance().bundleDict.Keys) { allBundleName.Add(bundleName); } foreach (var bundleName in allBundleName) { var bundleDict = getInstance().bundleDict; var bundlelist = BMDataAccessor.Bundles; var dependRefDict = getInstance().dependRefDict; var includeRefDict = getInstance().includeRefDict; if (!bundleDict.ContainsKey(bundleName)) { continue; } BundleData bundle = bundleDict[bundleName]; bundlelist.Remove(bundle); bundleDict.Remove(bundleName); var buildStatesDict = getInstance().statesDict; BMDataAccessor.BuildStates.Remove(buildStatesDict[bundleName]); buildStatesDict.Remove(bundleName); // Remove parent ref if (bundle.parent != "" && bundleDict.ContainsKey(bundle.parent)) { bundleDict[bundle.parent].children.Remove(bundleName); } // Remove include ref foreach (string assetPath in bundle.includs) { includeRefDict[assetPath].Remove(bundle); } // Remove depend asssets ref foreach (string assetPath in bundle.dependAssets) { dependRefDict[assetPath].Remove(bundle); } // Delete children recursively foreach (string childName in bundle.children) { RemoveBundle(childName); } } BMDataAccessor.SaveBundleData(); BMDataAccessor.SaveBundleBuildeStates(); }
/// <summary> /// Create a new bundle. /// 创建一个新的资源包 /// </summary> /// <param name="name">资源包名称_Name of the bundle name.</param> /// <param name="parent">资源包的父级资源包_New parent's name. Set the parent to empty string if you want create a new root bundle.</param> /// <param name="sceneBundle">是否为场景资源包_Is the bundle a scene bundle? </param> /// <returns></returns> static public bool CreateNewBundle(string name, string parent, bool sceneBundle) { var bundleDict = getInstance().bundleDict; if (bundleDict.ContainsKey(name)) { return(false); } BundleData newBundle = new BundleData(); newBundle.name = name; newBundle.sceneBundle = sceneBundle; if (parent != "") { if (!bundleDict.ContainsKey(parent)) { return(false); } else { bundleDict[parent].children.Add(name); } newBundle.parent = parent; } bundleDict.Add(name, newBundle); InsertBundleToBundleList(newBundle); BundleBuildState newBuildState = new BundleBuildState(); newBuildState.bundleName = name; getInstance().statesDict.Add(name, newBuildState); BMDataAccessor.BuildStates.Add(newBuildState); UpdateBundleChangeTime(newBundle.name); BMDataAccessor.SaveBundleData(); BMDataAccessor.SaveBundleBuildeStates(); if (!name.StartsWith("+")) { GM.BundleInfo newBundleInfo = new GM.BundleInfo(); newBundleInfo.BundleName = name; newBundleInfo.Parent = parent.StartsWith("+") ? "" : parent; newBundleInfo.Paths = new List <string>(); newBundleInfo.Includes = new List <string>(); newBundleInfo.Version = -1; BMDataAccessor.BundleShipInfos.Add(newBundleInfo); BMDataAccessor.SaveBundleShipInfoFile(); } return(true); }
internal static void UpdateAllBundleChangeTime() { foreach (BundleData bundle in bundles) { UpdateBundleChangeTime(bundle.name); } BMDataAccessor.SaveBundleBuildeStates(); }
private static bool BuildSingleBundle(BundleData bundle) { // Prepare bundle output dictionary string outputPath = GenerateOutputPathForBundle(bundle.name); string bundleStoreDir = Path.GetDirectoryName(outputPath); if (!Directory.Exists(bundleStoreDir)) { Directory.CreateDirectory(bundleStoreDir); } // Start build string[] assetPaths = GetAssetsFromPaths(BundleManager.GUIDsToPaths(bundle.includeGUIDs.ToArray()), bundle.sceneBundle); bool succeed = false; uint crc = 0; if (assetPaths.Length == 0) { Debug.LogError("No asset included in bundle " + bundle.name); } else { if (bundle.sceneBundle) { succeed = BuildSceneBundle(assetPaths, outputPath, out crc); } else { succeed = BuildAssetBundle(assetPaths, outputPath, out crc); } } // Remember the assets for next time build test BundleBuildState buildState = BundleManager.GetBuildStateOfBundle(bundle.name); if (succeed) { buildState.lastBuildDependencies = AssetDatabase.GetDependencies(assetPaths); buildState.version++; if (buildState.version == int.MaxValue) { buildState.version = 0; } buildState.crc = crc; System.IO.FileInfo bundleFileInfo = new System.IO.FileInfo(outputPath); buildState.size = bundleFileInfo.Length; } else { buildState.lastBuildDependencies = null; } BMDataAccessor.SaveBundleBuildeStates(); return(succeed); }
void RefreshAllBundle() { for (int i = 0; i < BundleManager.bundles.Length; i++) { BundleManager.RefreshBundleDependencies(BundleManager.bundles[i]); } BundleManager.RefreshExInclude(); BMDataAccessor.SaveBundleData(); }
private static SingleBundleEnd BuildSingleBundle(BundleData bundle) { // Prepare bundle output dictionary string outputPath = GenerateOutputPathForBundle(bundle.name); string bundleStoreDir = Path.GetDirectoryName(outputPath); if (!Directory.Exists(bundleStoreDir)) { Directory.CreateDirectory(bundleStoreDir); } // Start build string[] assetPathes = GetAssetsFromPaths(bundle.includs.ToArray(), bundle.sceneBundle); //如果无资源,并且不是common,则说明是一个废弃包 if (assetPathes.Length == 0) { return(SingleBundleEnd.eEmptyRemove); } bool succeed = false; if (bundle.sceneBundle) { succeed = BuildSceneBundle(assetPathes, outputPath); } else { succeed = BuildAssetBundle(assetPathes, outputPath); } // Remember the assets for next time build test BundleBuildState buildState = BundleManager.GetBuildStateOfBundle(bundle.name); if (succeed) { buildState.lastBuildDependencies = AssetDatabase.GetDependencies(assetPathes); buildState.version++; if (buildState.version == int.MaxValue) { buildState.version = 0; } FileInfo bundleFileInfo = new FileInfo(outputPath); buildState.size = bundleFileInfo.Length; } else { buildState.lastBuildDependencies = null; } BMDataAccessor.SaveBundleBuildeStates(); return(succeed ? SingleBundleEnd.eSucc : SingleBundleEnd.eFail); }
private void Init() { BMDataAccessor.Refresh(); includeRefDict.Clear(); dependRefDict.Clear(); bundleDict.Clear(); foreach (BundleData bundle in BMDataAccessor.Bundles) { if (!bundleDict.ContainsKey(bundle.name)) { bundleDict.Add(bundle.name, bundle); } else { Debug.LogError("Bundle manger -- Cannot have two bundle with same name [" + bundle.name + "]"); } foreach (string guid in bundle.includeGUIDs) { AddIncludeRef(guid, bundle); } AddDependRefs(bundle); } foreach (var bundle in bundleDict.Values) { if (!string.IsNullOrEmpty(bundle.parent)) { bundleDict[bundle.parent].GetChildren().Add(bundle.name); } } foreach (var bundle in bundleDict.Values) { bundle.GetChildren().Sort(); } statesDict.Clear(); foreach (BundleBuildState buildState in BMDataAccessor.BuildStates) { if (!statesDict.ContainsKey(buildState.bundleName)) { statesDict.Add(buildState.bundleName, buildState); } else { Debug.LogError("Bundle manger -- Cannot have two build states with same name [" + buildState.bundleName + "]"); } } UpdateAllBundlesNeedBuild(); }
void GUI_DeleteMenuCallback() { foreach (string bundle in m_Selections) { BundleManager.RemoveBundle(bundle); } BMDataAccessor.SaveBundleData(); m_Selections.Clear(); Repaint(); }
/** * Remove asset from bundle's include list by guid. */ public static void RemoveAssetFromBundle(string guid, string bundleName) { BundleData bundle = GetBundleData(bundleName); bundle.includeGUIDs.Remove(guid); RemoveIncludeRef(guid, bundle); RefreshBundleDependencies(bundle); UpdateBundleChangeTime(bundle.name); BMDataAccessor.SaveBundleData(); }
/** * Remove the bundle by the given name. * @Return Return false if no such bundle. */ static public bool RemoveBundle(string name) { var bundleDict = getInstance().bundleDict; var bundlelist = BMDataAccessor.Bundles; var dependRefDict = getInstance().dependRefDict; var includeRefDict = getInstance().includeRefDict; if (!bundleDict.ContainsKey(name)) { return(false); } BundleData bundle = bundleDict[name]; bundlelist.Remove(bundle); bundleDict.Remove(name); var buildStatesDict = getInstance().statesDict; BMDataAccessor.BuildStates.Remove(buildStatesDict[name]); buildStatesDict.Remove(name); // Remove parent ref if (bundle.parent != "" && bundleDict.ContainsKey(bundle.parent)) { bundleDict[bundle.parent].children.Remove(name); } // Remove include ref foreach (string guid in bundle.includeGUIDs) { if (includeRefDict.ContainsKey(guid)) { includeRefDict[guid].Remove(bundle); } } // Remove depend asssets ref foreach (string guid in bundle.dependGUIDs) { dependRefDict[guid].Remove(bundle); } // Delete children recursively foreach (string childName in bundle.children) { RemoveBundle(childName); } BMDataAccessor.SaveBundleData(); BMDataAccessor.SaveBundleBuildeStates(); return(true); }
/** * Remove path from bundle's include list. */ public static void RemovePathFromBundle(string path, string bundleName) { BundleData bundle = GetBundleData(bundleName); bundle.includs.Remove(path); getInstance().includeRefDict[path].Remove(bundle); RefreshBundleDependencies(bundle); UpdateBundleChangeTime(bundle.name); BMDataAccessor.SaveBundleData(); }
private void Init() { BMDataAccessor.Refresh(); statesDict.Clear(); includeRefDict.Clear(); dependRefDict.Clear(); foreach (BundleBuildState buildState in BMDataAccessor.BuildStates) { if (!statesDict.ContainsKey(buildState.bundleName)) { statesDict.Add(buildState.bundleName, buildState); } else { EB.Debug.LogError("Bundle manger -- Cannot have two build states with same name [{0}]", buildState.bundleName); } } bundleDict.Clear(); foreach (BundleData bundle in BMDataAccessor.Bundles) { if (!bundleDict.ContainsKey(bundle.name)) { bundleDict.Add(bundle.name, bundle); } else { EB.Debug.LogError("Bundle manger -- Cannot have two bundle with same name [{0}]", bundle.name); } if (!statesDict.ContainsKey(bundle.name)) { statesDict.Add(bundle.name, new BundleBuildState()); // Don't have build state of the this bundle. Add a new one. } foreach (string guid in bundle.includeGUIDs) { AddIncludeRef(guid, bundle); } foreach (string guid in bundle.exIncludeGUIDs) { AddExIncludeRef(guid, bundle); } AddDependRefs(bundle); } }
static void OnPostprocessAllAssets(string[] importAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPathes) { #if IIPS List <string> changedAssets = new List <string>(); changedAssets.AddRange(importAssets); changedAssets.AddRange(deletedAssets); changedAssets.AddRange(movedFromPathes); List <string> createdAssets = new List <string>(); createdAssets.AddRange(importAssets); createdAssets.AddRange(movedAssets); bool dataChanged = false; foreach (string assetPath in changedAssets) { List <BundleData> bundles = BundleManager.GetRelatedBundles(assetPath); if (bundles == null) { continue; } foreach (BundleData bundle in bundles.ToArray()) // Use ToArray to make a copy to prevent change the org bundle list. { BundleManager.RefreshBundleDependencies(bundle); dataChanged = true; } } foreach (string assetPath in createdAssets) { foreach (BundleData bundle in BundleManager.bundles) { foreach (string include in bundle.includs) { if (assetPath.Contains(include)) { BundleManager.RefreshBundleDependencies(bundle); dataChanged = true; } } } } if (dataChanged) { BMDataAccessor.SaveBundleData(); } #endif }
/** * Set the parent of the bundle. * @param parent New parent bundle's name. Set the parent to empty if you want the childe bundle become a root bundle. */ static public void SetParent(string childe, string parent) { if (!CanBundleParentTo(childe, parent)) { return; } var bundleDict = getInstance().bundleDict; if (!bundleDict.ContainsKey(childe) || (parent != "" && !bundleDict.ContainsKey(parent))) { return; } BundleData childeBundle = bundleDict[childe]; if (bundleDict.ContainsKey(childeBundle.parent)) { bundleDict[childeBundle.parent].children.Remove(childe); } string origParent = childeBundle.parent; childeBundle.parent = parent; if (parent != "") { BundleData newParentBundle = bundleDict[parent]; newParentBundle.children.Add(childe); newParentBundle.children.Sort(); } if (parent == "" || origParent == "") { BMDataAccessor.Bundles.Remove(childeBundle); InsertBundleToBundleList(childeBundle); } UpdateBundleChangeTime(childeBundle.name); BMDataAccessor.SaveBundleData(); GM.BundleInfo bundleInfo = BMDataAccessor.BundleShipInfos.Find(item => item.BundleName == childe); if (bundleInfo != null) { bundleInfo.Parent = parent.StartsWith("+") ? "" : parent; } BMDataAccessor.SaveBundleShipInfoFile(); }
/** * Add a path to bundle's include list. * @param path The path must be a path under Asset. Can be path of diretory or file. * @param bundleName The bundle's name. */ public static void AddPathToBundle(string path, string bundleName) { BundleData bundle = GetBundleData(bundleName); if (IsNameDuplicatedAsset(bundle, path)) { UnityEngine.Debug.LogWarning("Name of new add asset will be duplicate with asset in bundle " + bundleName + ". This may cause problem when you trying to load them."); } bundle.includs.Add(path); AddIncludeRef(path, bundle); RefreshBundleDependencies(bundle); UpdateBundleChangeTime(bundle.name); BMDataAccessor.SaveBundleData(); }
private static void checkOldVersion() { if (BMDataAccessor.BMConfiger.bmVersion == 0) { EditorUtility.DisplayDialog("Bundle Manager Upgrade", "Welcome to new version. Bundle Manager will upgrade your Bundle Data files to new version.", "OK"); BMDataAccessor.BMConfiger.bmVersion = 1; foreach (BundleData bundle in BMDataAccessor.Bundles) { bundle.includeGUIDs = PathsToGUIDs(bundle.includs); bundle.dependGUIDs = PathsToGUIDs(bundle.dependAssets); } BMDataAccessor.SaveBundleData(); BMDataAccessor.SaveBMConfiger(); } }
/** * Create a new bundle. * @param name Name of the bundle name. * @param parent New parent's name. Set the parent to empty string if you want create a new root bundle. * @param sceneBundle Is the bundle a scene bundle? */ static public bool CreateNewBundle(string name, string parent, BundleType bundleType) { var bundleDict = getInstance().bundleDict; if (bundleDict.ContainsKey(name)) { return(false); } BundleData newBundle = new BundleData(); newBundle.name = name; //newBundle.sceneBundle = sceneBundle; newBundle.bundleType = bundleType; if (parent != "") { if (!bundleDict.ContainsKey(parent)) { return(false); } else { bundleDict[parent].GetChildren().Add(name); } newBundle.parent = parent; } bundleDict.Add(name, newBundle); InsertBundleToBundleList(newBundle); BundleBuildState newBuildState = new BundleBuildState(); newBuildState.bundleName = name; getInstance().statesDict.Add(name, newBuildState); BMDataAccessor.BuildStates.Add(newBuildState); UpdateBundleChangeTime(newBundle.name); BMDataAccessor.SaveBundleData(); BMDataAccessor.SaveBundleBuildeStates(); return(true); }
/** * Build bundles. */ public static void BuildBundles(string[] bundles) { Dictionary <string, List <string> > buildingRoutes = new Dictionary <string, List <string> >(); foreach (string bundle in bundles) { AddBundleToBuildList(bundle, ref buildingRoutes); } m_BuiltCount = 0; var startTime = Time.realtimeSinceStartup; foreach (var buildRoute in buildingRoutes) { BundleData bundle = BundleManager.GetBundleData(buildRoute.Key); if (bundle != null) { BuildBundleTree(bundle, buildRoute.Value); } } BMDataAccessor.BuildVersion++; BMDataAccessor.SaveBundleBuildVersion(); BMDataAccessor.SaveBundleVersionInfo(); string exportpath = BuildConfiger.InterpretedOutputPath; if (!Directory.Exists(exportpath)) { Directory.CreateDirectory(exportpath); } BundleManager.UpdateAllBundlesNeedBuild(); uint crc = 0; if (!BuildAssetBundle(new string[] { BMDataAccessor.BundleBuildVersionPath, BMDataAccessor.BMConfigerPath }, Path.Combine(exportpath, "BM.data"), out crc)) { //存入数据,三个path指向三个txt文件,将三个txt文件导入BM.data Debug.LogError("Failed to build bundle of config files."); } Debug.Log("Build bundles:" + m_BuiltCount + "| AssetBundleVersion:" + BMDataAccessor.BuildVersion + "| Time Consumed" + (Time.realtimeSinceStartup - startTime)); File.WriteAllText(Path.Combine(exportpath, "BMDataVersion.txt"), BMDataAccessor.BuildVersion.ToString()); }
private static void checkOldVersion() { if (BMDataAccessor.BMConfiger.bmVersion == 0) { EditorUtility.DisplayDialog("Bundle Manager Upgrade", "Welcome to new version. Bundle Manager will upgrade your Bundle Data files to new version.", "OK"); BMDataAccessor.BMConfiger.bmVersion = 1; //MARK:原生功能中检查Api更新的机制,因为已经改变了数据结构所有现在不用了 //foreach(BundleData bundle in BMDataAccessor.Bundles) //{ // bundle.includeGUIDs = PathsToGUIDs(bundle.includs); // bundle.dependGUIDs = PathsToGUIDs(bundle.dependAssets); //} BMDataAccessor.ShouldSaveBundleData = true; BMDataAccessor.SaveBMConfiger(); } }
/** * Add a path to bundle's include list. * @param path The path must be a path under Asset. Can be path of diretory or file. * @param bundleName The bundle's name. */ public static void AddPathToBundle(string path, string bundleName) { BundleData bundle = GetBundleData(bundleName); if (IsNameDuplicatedAsset(bundle, path)) { EB.Debug.LogWarning("Name of new add asset will be duplicate with asset in bundle {0}. This may cause problem when you trying to load them.", bundleName); } string guid = AssetDatabase.AssetPathToGUID(path); bundle.includeGUIDs.Add(guid); AddIncludeRef(guid, bundle); RefreshBundleDependencies(bundle); UpdateBundleChangeTime(bundle.name); BMDataAccessor.SaveBundleData(); }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string asset in importedAssets) { if (asset == BMDataAccessor.BundleDataPath || asset == BMDataAccessor.BundleBuildStatePath) { if (isDateChangedManually(asset)) { BundleManager.RefreshAll(); } } else if (asset == BMDataAccessor.BMConfigerPath || asset == BMDataAccessor.UrlDataPath) { if (isDateChangedManually(asset)) { BMDataAccessor.Refresh(); } } } }
/** * Set the parent of the bundle. * @param parent New parent bundle's name. Set the parent to empty if you want the childe bundle become a root bundle. */ static public void SetParent(string childe, string parent) { if (!CanBundleParentTo(childe, parent)) { return; } var bundleDict = getInstance().bundleDict; if (!bundleDict.ContainsKey(childe) || (parent != "" && !bundleDict.ContainsKey(parent))) { return; } BundleData childeBundle = bundleDict[childe]; if (bundleDict.ContainsKey(childeBundle.parent)) { bundleDict[childeBundle.parent].children.Remove(childe); } string origParent = childeBundle.parent; childeBundle.parent = parent; if (parent != "") { BundleData newParentBundle = bundleDict[parent]; newParentBundle.children.Add(childe); newParentBundle.children.Sort(); } if (parent == "" || origParent == "") { BMDataAccessor.Bundles.Remove(childeBundle); InsertBundleToBundleList(childeBundle); } UpdateBundleChangeTime(childeBundle.name); BMDataAccessor.SaveBundleData(); }
/** * Rename the bundle. * @Return Return false if there's no such bundle, or the new name is used. */ static public bool RenameBundle(string origName, string newName) { if (newName == "" || origName == newName || getInstance().bundleDict.ContainsKey(newName) || !getInstance().bundleDict.ContainsKey(origName)) { return(false); } BundleData bundle = getInstance().bundleDict[origName]; bundle.name = newName; Dictionary <string, BundleData> bundleDict = getInstance().bundleDict; bundleDict.Remove(origName); bundleDict.Add(newName, bundle); if (bundle.parent != "") { BundleData parentBundle = bundleDict[bundle.parent]; parentBundle.children.Remove(origName); parentBundle.children.Add(newName); } foreach (string childName in bundle.children) { getInstance().bundleDict[childName].parent = newName; } var buildStatesDic = getInstance().statesDict; BundleBuildState buildState = buildStatesDic[origName]; buildState.bundleName = newName; buildStatesDic.Remove(origName); buildStatesDic.Add(newName, buildState); BMDataAccessor.SaveBundleData(); BMDataAccessor.SaveBundleBuildeStates(); return(true); }
public void SaveBundleShipInfoFile() { try { System.IO.TextWriter tw = new System.IO.StreamWriter(mBundleInfoFilePath); string jsonStr = JsonFormatter.PrettyPrint(GM.JSON.ToJson(mCurrentEditItems)); tw.Write(jsonStr); tw.Flush(); tw.Close(); if (BundleTreeWin.IsOpen) { BMDataAccessor.ReloadBundleShipInfos(); } BuildHelper.ExportBundleShipInfoFileToOutput(); } catch (System.Exception ex) { Debug.Log(ex.ToString()); } }
private static void BuildAll() { InitState(); LoadShaderList(); List <string> buildList = GetObjectPathByConfig(); List <BundleData> bundles = new List <BundleData>(); for (int i = 0; i < buildList.Count; i++) { bundles.Add(AddRootBundleData(buildList[i])); } for (int i = 0; i < bundles.Count; i++) { if (BuildHelp.BuildRootBundle(bundles[i])) { DependsData.Add(CreateDependsData(bundles[i])); } } //BuildPipeline.BuildAssetBundles() // if (DependsData.Count > 0) { string dependsConfigPath = BuildHelp.GenerateOutputDependsPath(); BMDataAccessor.SaveBundleBuildeStates(); BMDataAccessor.SaveObjectToJsonFile <List <BundleDependsData> >(DependsData, dependsConfigPath); BMDataAccessor.SaveReleaseDependsData(DependsData, BundleSetting.PlatformOutputPath + "/DependsData.release"); BMDataAccessor.ClearBundleBuildStates(DependsData); DependsData.Clear(); } else { Debug.Log("There is no written DependsData.txt!"); } }
public static void BuildAloneSelectObject() { Object[] objs = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets); if (objs.Length == 0) { return; } InitState(); List <BundleData> bundles = Objects2Bundles(objs); for (int i = 0; i < bundles.Count; i++) { if (BuildHelp.BuildRootBundle(bundles[i])) { DependsData.Add(CreateDependsData(bundles[i])); } } string dependsConfigPath = BuildHelp.GenerateOutputDependsPath(); if (File.Exists(dependsConfigPath)) { List <BundleDependsData> diskConfigData = BMDataAccessor.LoadObjectFromJsonFile <List <BundleDependsData> >(dependsConfigPath); for (int i = 0; i < DependsData.Count; i++) { InsertBundleData(DependsData[i], ref diskConfigData); } BMDataAccessor.SaveObjectToJsonFile <List <BundleDependsData> >(diskConfigData, dependsConfigPath); } else { BMDataAccessor.SaveObjectToJsonFile <List <BundleDependsData> >(DependsData, dependsConfigPath); } }