private static void _ProcessUpdateBundleList(string bundleName, BundleImportData selectData, FilterHandler filter) { BundleData data = BundleDataManager.GetBundleData(bundleName); if (data == null) { return; } for (int i = 0; i < data.includs.Count; ++i) { if (filter == null || filter(data.includs[i])) { _AddToDict(data.name, m_bundleDict); continue; } if (!selectData.Publish) { continue; } string[] dep = AssetDepend.GetDependenciesCache(data.includs[i]); for (int k = 0; k < dep.Length; ++k) { if (!filter(dep[k])) { continue; } if (!BundleDataManager.CheckPathInBundle(dep[k])) { _AddToDict(data.name, m_bundleDict); break; } } } }
public static void UpdateBundleBuildList(FilterHandler filter) { if (filter == null) { m_useFilter = false; return; } m_useFilter = true; List <BundleImportData> dataList = m_dataControl.DataList; for (int l = 0; l < dataList.Count; ++l) { BundleImportData data = dataList[l]; if (data == null) { continue; } if (EditorUtility.DisplayCancelableProgressBar("Update Bundle List", data.RootPath, (l * 1.0f) / dataList.Count)) { Debug.LogWarning("CreateBundles Stop."); break; } string parentName = BundleDataManager.GetIndexBundleName(l); BundleData parent = BundleDataManager.GetBundleData(parentName); for (int i = 0; parent != null && i < parent.children.Count; ++i) { _ProcessUpdateBundleList(parent.children[i], data, filter); } } EditorUtility.ClearProgressBar(); _ProcessDependBundleList(); }
private static void _PreProcessSpecialBundle() { BundleData shader = BundleDataManager.GetBundleData(BundleName.BN_SHADER); if (shader == null) { BundleDataManager.CreateNewBundle(BundleName.BN_SHADER, "", BundleType.None, BundleLoadState.UnLoadOnUnloadAsset); shader = BundleDataManager.GetBundleData(BundleName.BN_SHADER); } if (shader.children.Count == 0) { string name = BundleDataManager.GenBundleNameByType(BundleType.Shader); BundleDataManager.CreateNewBundle(name, shader.name, BundleType.Shader, BundleLoadState.PreLoad); } _AddToDict(shader.name, m_bundleDict); BundleData script = BundleDataManager.GetBundleData(BundleName.BN_SCRIPT); if (script == null) { BundleDataManager.CreateNewBundle(BundleName.BN_SCRIPT, "", BundleType.None, BundleLoadState.UnLoadOnUnloadAsset); script = BundleDataManager.GetBundleData(BundleName.BN_SCRIPT); } if (script.children.Count == 0) { string name = BundleDataManager.GenBundleNameByType(BundleType.Script); BundleDataManager.CreateNewBundle(name, script.name, BundleType.Script, BundleLoadState.PreLoad); } _AddToDict(script.name, m_bundleDict); }
public static void BuildBundles() { BundleBuildHelper.PushAssetDependencies(); BuildSingleBundle(BundleName.BN_SCRIPT, null); BundleData shader = BundleDataManager.GetBundleData(BundleName.BN_SHADER); for (int i = 0; shader != null && i < shader.children.Count; ++i) { BundleData shaderChild = BundleDataManager.GetBundleData(shader.children[i]); BundleState childState = BundleDataManager.GetBundleState(shader.children[i]); bool result = BundleBuildHelper.BuildShaderBundle(shaderChild, childState); if (!result) { Debug.LogErrorFormat("[BundleAdapter] BuildShaderBundle {0} Failed.", shader.children[i]); } } List <BundleImportData> dataList = m_dataControl.DataList; for (int i = 0; i < dataList.Count; ++i) { BundleImportData data = dataList[i]; string parentName = BundleDataManager.GetIndexBundleName(i); BuildSingleBundle(parentName, data); } BundleBuildHelper.PopAssetDependencies(); BundleExport.ExportBundleMainfestToOutput(); AssetDatabase.SaveAssets(); }
private static void BuildSingleBundle(string name, BundleImportData data) { BundleData bundle = BundleDataManager.GetBundleData(name); if (bundle == null) { return; } for (int i = 0; i < bundle.children.Count; ++i) { BundleData child = BundleDataManager.GetBundleData(bundle.children[i]); BundleState childState = BundleDataManager.GetBundleState(bundle.children[i]); if (child == null || child.includs.Count == 0 || childState == null) { continue; } if (m_buildAll && !m_bundleDict.ContainsKey(child.name)) { continue; } bool result = BundleBuildHelper.BuildSingleBundle(child, childState, data == null ? false : data.PushDependice); if (!result) { Debug.LogErrorFormat("[BundleAdapter] BuildSingleBundle {0} Failed.", child.name); } } }
void OnEnable() { if (m_bundleDataViewer == null) { BundleDataManager.Init(); m_bundleDataViewer = new BundleViewer(this); } }
private static void ProcessSpecialResource(string path) { if (m_specialCache.ContainsKey(path)) { return; } m_specialCache.Add(path, path); if (EditorPath.IsShader(path)) { if (!BundleDataManager.CheckPathInBundle(path)) { BundleData shader = BundleDataManager.GetBundleData(BundleName.BN_SHADER); if (shader != null && shader.children.Count > 0) { BundleDataManager.AddPathToBundle(path, shader.children[0], 1024); } } } else if (EditorPath.IsMaterial(path)) { BundleData shaderBundle = BundleDataManager.GetBundleData(BundleName.BN_SHADER); if (shaderBundle == null) { return; } UnityEngine.Object[] assetAtPath = AssetDatabase.LoadAllAssetsAtPath(path); foreach (var obj in assetAtPath) { if (obj != null && obj.GetType() == typeof(Material)) { Material mat = obj as Material; if (mat != null && mat.shader != null && !string.IsNullOrEmpty(mat.shader.name)) { if (!shaderBundle.includs.Contains(mat.shader.name)) { shaderBundle.includs.Add(mat.shader.name); } } } if ((!(obj is GameObject)) && (!(obj is Component))) { Resources.UnloadAsset(obj); } } ProcessClear(); } else if (EditorPath.IsScript(path)) { BundleData script = BundleDataManager.GetBundleData(BundleName.BN_SCRIPT); if (script != null && script.children.Count > 0) { BundleDataManager.AddPathToBundle(path, script.children[0], 1024); } } }
private static void ProcessUpdateBundleList(string bundleName) { BundleData data = BundleDataManager.GetBundleData(bundleName); if (data == null) { return; } for (int i = 0; i < data.includs.Count; ++i) { _AddToDict(data.name, m_bundleDict); } }
public void OnDataSelected(object selected, int col) { BundleImportData importData = selected as BundleImportData; if (importData == null) { return; } m_editorData.CopyData(importData); m_index = importData.Index; if (m_bundleTable != null) { m_bundleTable.RefreshData(BundleDataManager.GetIndexBundleList(importData.Index)); } }
private static void _ProcessDependBundleList() { bool loop = true; while (loop) { loop = false; List <string> list = new List <string>(m_bundleDict.Keys); for (int i = 0; i < list.Count; ++i) { bool isProcess = false; if (!m_bundleDict.TryGetValue(list[i], out isProcess)) { continue; } if (isProcess) { continue; } m_bundleDict[list[i]] = true; loop = true; BundleData data = BundleDataManager.GetBundleData(list[i]); if (data == null) { continue; } for (int j = 0; j < data.includs.Count; ++j) { string[] dep = AssetDepend.GetDependenciesCache(data.includs[j]); for (int k = 0; k < dep.Length; ++k) { string bundleName = BundleDataManager.GetPathBundleName(dep[k]); if (!string.IsNullOrEmpty(bundleName)) { _AddToDict(bundleName, m_bundleDict); } } } } } }
public static void BuildBundles() { //ModelDataControl dataControl = new ModelDataControl(null, null); //BuildHelper.SetDelegate(dataControl.FilterObject); BuildHelper.PushAssetDependencies(); //BuildHelper.BuildShaderBundle(); _BuildSingleBundle(BundleName.BN_SCRIPT, null); List <BundleImportData> dataList = m_dataControl.DataList; for (int i = 0; i < dataList.Count; ++i) { BundleImportData data = dataList[i]; string parentName = BundleDataManager.GetIndexBundleName(i); _BuildSingleBundle(parentName, data); } BuildHelper.PopAssetDependencies(); //BuildHelper.ExportBMDatasToOutput(); AssetDatabase.SaveAssets(); }
private static void _BuildSingleBundle(string name, BundleImportData data) { BundleData bundle = BundleDataManager.GetBundleData(name); if (bundle == null) { return; } for (int i = 0; i < bundle.children.Count; ++i) { BundleData child = BundleDataManager.GetBundleData(bundle.children[i]); BundleState childState = BundleDataManager.GetBundleState(bundle.children[i]); if (child == null || child.includs.Count == 0 || childState == null) { continue; } if (m_useFilter && !m_bundleDict.ContainsKey(child.name)) { continue; } BuildHelper.BuildSingleBundle(child, childState, data.PushDependice); } }
public void Draw(Rect r) { int border = 10; float splitH = 0.4f; float splitW = 0.5f; int toolbarHeight = 80; float spacePixel = 10.0f; //GUILayout.BeginArea(r); GUILayout.BeginVertical(); m_control.Draw(); BundleImportData data = m_control.Data; GUILayout.BeginHorizontal(TableStyles.Toolbar); { EditorGUILayout.LabelField("LimitCount : "); data.LimitCount = EditorGUILayout.IntField(data.LimitCount); GUILayout.Space(spacePixel); EditorGUILayout.LabelField("LimitKBSize : "); data.LimitKBSize = EditorGUILayout.IntField(data.LimitKBSize); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(TableStyles.Toolbar); { EditorGUILayout.LabelField("BundleType : "); data.Type = (BundleType)EditorGUILayout.EnumPopup(data.Type); GUILayout.Space(spacePixel); EditorGUILayout.LabelField("LoadState: "); data.LoadState = (BundleLoadState)EditorGUILayout.EnumPopup(data.LoadState); GUILayout.Space(spacePixel); data.Publish = GUILayout.Toggle(data.Publish, " Publish"); GUILayout.Space(spacePixel); data.PushDependice = GUILayout.Toggle(data.PushDependice, " Push"); GUILayout.Space(spacePixel); data.SkipData = GUILayout.Toggle(data.SkipData, " SkipData"); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(TableStyles.Toolbar); { if (GUILayout.Button("Move Up Priority", TableStyles.ToolbarButton, GUILayout.MaxWidth(120))) { m_control.ModifDataPriority(true); } if (GUILayout.Button("Move Down Priority", TableStyles.ToolbarButton, GUILayout.MaxWidth(120))) { m_control.ModifDataPriority(false); } if (GUILayout.Button("Create Bundle", TableStyles.ToolbarButton, GUILayout.MaxWidth(140))) { m_control.RefreshBaseData(); BundleAdapter.CreateBundles(); } if (GUILayout.Button("Build All Bundle", TableStyles.ToolbarButton, GUILayout.MaxWidth(140))) { BundleAdapter.UpdateBundleBuildList(); BundleAdapter.BuildBundles(); } if (GUILayout.Button("Clear All Bundle", TableStyles.ToolbarButton, GUILayout.MaxHeight(140))) { BundleDataManager.RemoveAllBundle(); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); int startY = toolbarHeight + border; int height = (int)(r.height - startY - border * 2); if (m_dataTable != null) { m_dataTable.Draw(new Rect(border, startY, r.width - border, (int)(height * splitH - border * 1.5f))); } if (m_bundleTable != null) { m_bundleTable.Draw(new Rect(border, (int)(height * splitH + border * 0.5f + startY), (int)(r.width * splitW) - border * 1.5f, (int)(height * (1.0f - splitH) - border * 1.5f))); } if (m_assetTable != null) { m_assetTable.Draw(new Rect((int)(r.width * splitW) + border * 0.5f, (int)(height * splitH + border * 0.5f + startY), (int)(r.width * (1.0f - splitW)) - border * 1.5f, (int)(height * (1.0f - splitH) - border * 1.5f))); } GUILayout.EndVertical(); //GUILayout.EndArea(); }
public static void ExportBundleDictToOutput() { EditorTool.CreateDirectory(BuildConfig.InterpretedOutputPath); BundleDataControl dataControl = BundleDataControl.Instance; BundleMainfest bundleMainfest = new BundleMainfest(); BundleData[] bundleData = BundleDataAccessor.Datas.ToArray(); Dictionary <string, string> dict = new Dictionary <string, string>(); for (int i = 0; i < bundleData.Length; ++i) { for (int j = 0; j < bundleData[i].includs.Count; ++j) { string path = bundleData[i].includs[j]; if (string.IsNullOrEmpty(path)) { continue; } if (!dict.ContainsKey(path)) { dict.Add(path, bundleData[i].name); } else { Debug.LogWarningFormat("[BundleExport] Path to bundle name have same path {0} : {1} _ {2}", path, bundleData[i].name, dict[path]); } BundleImportData data = dataControl.GetPathImportData(path); if (data == null || !data.Publish || !path.StartsWith("Assets", StringComparison.OrdinalIgnoreCase)) { continue; } string bundlePath = path; // format path to load path!!! bundleMainfest.AddPathToBundle(bundlePath, bundleData[i].name); } } for (int i = 0; i < bundleData.Length; ++i) { for (int j = 0; j < bundleData[i].includs.Count; ++j) { string[] dep = AssetDepot.GetDependenciesCache(bundleData[i].includs[j]); for (int k = 0; k < dep.Length; ++k) { if (EditorPath.IsScript(dep[k]) || EditorPath.IsShader(dep[k])) { continue; } string bundleName = null; dict.TryGetValue(EditorPath.NormalizePathSplash(dep[k]), out bundleName); if (string.IsNullOrEmpty(bundleName) || bundleName == bundleData[i].name) { continue; } BundleState childBuildState = BundleDataManager.GetBundleState(bundleName); if (childBuildState.loadState == BundleLoadState.Preload || childBuildState.size == -1) { continue; } bundleMainfest.AddBundleDepend(bundleData[i].name, bundleName); } } } List <BundleState> stateList = new List <BundleState>(BundleDataAccessor.States); bundleMainfest.AddBundleState(stateList); bundleMainfest.SaveBytes(BuildConfig.BundleMainfestOutputPath); AssetDatabase.ImportAsset(BuildConfig.BundleMainfestOutputPath, ImportAssetOptions.ForceSynchronousImport); }
private static void _AddPathToBundleByPathConfig(BundleImportData data, string path) { if (data == null || string.IsNullOrEmpty(path) || BundleDataManager.CheckPathInBundle(path)) { return; } string parentName = BundleDataManager.GetIndexBundleName(data.Index); if (data.Type == BundleType.Shader) { parentName = BundleName.BN_SHADER; } string bundleName = BundleDataManager.GetPathBundleName(path); if (!string.IsNullOrEmpty(bundleName)) { BundleData bundleData = BundleDataManager.GetBundleData(bundleName); if (bundleData.parent == parentName) { return; } else { BundleDataManager.RemovePathFromBundle(path, bundleName); } } _AddToDict(bundleName, m_bundleDict); BundleData parent = BundleDataManager.GetBundleData(parentName); if (parent == null) { BundleDataManager.CreateNewBundle(parentName, "", BundleType.None, BundleLoadState.UnLoadOnUnloadAsset); parent = BundleDataManager.GetBundleData(parentName); } string name = ""; for (int i = 0; i < parent.children.Count; ++i) { int index = parent.children.Count - i - 1; BundleData child = BundleDataManager.GetBundleData(parent.children[index]); if (BundleDataManager.IsBundleFull(child, data.LimitCount, data.LimitKBSize * 1024)) { continue; } if (data.Publish && BundleDataManager.IsNameDuplicatedAsset(child, path)) { continue; } name = child.name; break; } if (string.IsNullOrEmpty(name)) { name = BundleDataManager.GenBundleNameByType(data.Type); BundleDataManager.CreateNewBundle(name, parent.name, data.Type, data.LoadState); } long size = CalcPathFileSize(path, data.Type); BundleDataManager.AddPathToBundle(path, name, size); _AddToDict(name, m_bundleDict); }
public static void ClearBundles() { BundleDataManager.RemoveAllBundle(); }