/// <summary> /// 资源打包 /// </summary> public void BuildAssetBundle(BuildTarget buildPlatform) { AssetDatabase.RemoveUnusedAssetBundleNames(); string rootPath = AppPaths.DataPathResDataRoot; if (!Directory.Exists(rootPath)) { EditorUtility.DisplayDialog("警告!", "所需资源目录不存在:" + rootPath, "确定"); return; } string[] assetLabelRoots = Directory.GetDirectories(rootPath); if (assetLabelRoots.Length == 0) { EditorUtility.DisplayDialog("提示!", "没有需要打包的资源!!!", "确定"); return; } ShipDockEditorData editorData = ShipDockEditorData.Instance; editorData.outputRoot = AppPaths.StreamingResDataRoot; editorData.platformPath = GetSuffix(buildPlatform); editorData.buildPlatform = buildPlatform; UnityEngine.Object[] selections = Selection.GetFiltered <UnityEngine.Object>(SelectionMode.DeepAssets); ShipDockEditorData.Instance.selections = selections; AssetBundleInfoPopupEditor.Popup(); }
protected override void CheckGUI() { base.CheckGUI(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("资源包名称:"); //ValueItemTextField("abName"); //ValueItemTextField("abPath"); EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); ResList = ShipDockEditorData.Instance.selections; CreateAssetItemWithButton(); string abName = string.Empty; if (GUILayout.Button("Build")) { ShipDockEditorData editorData = ShipDockEditorData.Instance; editorData.ABCreaterMapper?.Clear(); Utils.Reclaim(ref editorData.ABCreaterMapper, false); editorData.ABCreaterMapper = new KeyValueList <string, List <ABAssetCreater> >(); CreateAssetImporters(ref abName, ref editorData.ABCreaterMapper); string output = editorData.outputRoot;//.Append(abPath); if (!Directory.Exists(output)) { Directory.CreateDirectory(output); } BuildAssetByCreater(); //BuildPipeline.BuildAssetBundles(output, BuildAssetBundleOptions.None, editorData.buildPlatform); if (EditorUtility.DisplayDialog("提示", string.Format("资源打包完成!!!"), "OK")) { AssetDatabase.Refresh(); } } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); }
private void BuildAssetByCreater() { ShipDockEditorData editorData = ShipDockEditorData.Instance; string abName; string output; List <ABAssetCreater> list; int max = editorData.ABCreaterMapper.Size; List <string> abNames = editorData.ABCreaterMapper.Keys; List <List <ABAssetCreater> > creaters = editorData.ABCreaterMapper.Values; for (int i = 0; i < max; i++) { abName = abNames[i]; list = creaters[i]; int m = list.Count; for (int n = 0; n < m; n++) { list[n].Importer.assetBundleName = abName; Debug.Log(abName); } //output = editorData.outputRoot.Append(abName); //Debug.Log(output); //if (!Directory.Exists(output)) //{ // Directory.CreateDirectory(output); //} //for (int n = 0; n < m; n++) //{ // list[n].Importer.assetBundleName = default; //} } BuildPipeline.BuildAssetBundles(editorData.outputRoot, BuildAssetBundleOptions.None, editorData.buildPlatform); }