public static void Execute(UnityEditor.BuildTarget target) { allmat = AssetDatabase.FindAssets("t:Prefab", folders); maxNum = allmat.Length; curNum = 0; _target = target; SavePath = AssetBundleController.GetPlatformPath(_target); for (int i = 0; i < maxNum; i++) { curNum = i; path = AssetDatabase.GUIDToAssetPath(allmat[curNum]); if (path.Contains("3D")) { continue; } Object obj = AssetDatabase.LoadAssetAtPath(path, typeof(Object)); path = SavePath + obj.name; path += ".assetbundle"; Debug.Log(path); BuildPipeline.BuildAssetBundle(obj, null, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, _target); } EditorUtility.DisplayDialog("", "一键打包", "OK"); //VisualAutuPack win = (VisualAutuPack)EditorWindow.GetWindowWithRect(typeof(VisualAutuPack), new Rect(Screen.width / 2 - 300, Screen.height / 2, 600, 400), true, "打包中"); }
public static void Execute(UnityEditor.BuildTarget target) { string SavePath = AssetBundleController.GetPlatformPath(target); Object obj = AssetDatabase.LoadAssetAtPath(SavePath + "VersionNum/VersionNum.xml", typeof(Object)); BuildPipeline.BuildAssetBundle(obj, null, SavePath + "VersionNum/VersionNum.assetbundle", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, target); AssetDatabase.Refresh(); }
public static void ExecuteAnim(UnityEditor.BuildTarget target) { allmat = AssetDatabase.FindAssets("t:AnimationClip", folders); Dictionary <string, List <Object> > animMap = new Dictionary <string, List <Object> >(); string strKey = string.Empty; SavePath = AssetBundleController.GetPlatformPath(target); for (int i = 0; i < allmat.Length; i++) { path = AssetDatabase.GUIDToAssetPath(allmat[i]); if (path.Contains("Models/Animations") == false) { continue; } Object obj = AssetDatabase.LoadAssetAtPath(path, typeof(Object)); strKey = path.Split('/')[3]; if (animMap.ContainsKey(strKey) == false) { List <Object> animObj = new List <Object>(); animObj.Clear(); animMap.Add(strKey, animObj); animMap[strKey].Add(obj); } else { animMap[strKey].Add(obj); } } foreach (KeyValuePair <string, List <Object> > item in animMap) { StringBuilder animName = new StringBuilder(); animName.Append(item.Key); animName.Append("_Anim"); string exportPate = SavePath + animName.ToString() + ".assetbundle"; Object[] list = item.Value.ToArray(); BuildPipeline.BuildAssetBundle(null, list, exportPate, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, target); } EditorUtility.DisplayDialog("", "一键所有动作组件bundle", "OK"); AssetDatabase.Refresh(); }
public static void ExecuteAll(UnityEditor.BuildTarget target, string name) { //清空一下缓存 Caching.CleanCache(); string SavePath = AssetBundleController.GetPlatformPath(target); if (SavePath.Length != 0) { Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); string exportPate = SavePath + name + ".assetbundle"; BuildPipeline.BuildAssetBundle(null, SelectedAsset, exportPate, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, target); } AssetDatabase.Refresh(); }
void OnGUI() { if (GUI.Button(new Rect(40f, 20f, 200f, 50f), "创建assetbundle散包")) { CreateAssetBundle.Execute(buildTarget); EditorUtility.DisplayDialog("", "创建assetbundle散包", "OK"); } if (GUI.Button(new Rect(40f, 90f, 200f, 50f), "创建assetbundle整包")) { string filename = EditorUtility.SaveFilePanel("", AssetBundleController.GetPlatformPath(buildTarget), "输入bundle名称,点击保存", "assetbundle"); CreateAssetBundle.ExecuteAll(filename, buildTarget); EditorUtility.DisplayDialog("", filename, "OK"); } if (GUI.Button(new Rect(300f, 20f, 200f, 50f), "一键所有prefab散包")) { VisualAutuPack.Execute(buildTarget); //CreateAssetBundle.Execute(buildTarget); //EditorUtility.DisplayDialog("", "创建assetbundle散包", "OK"); } if (GUI.Button(new Rect(300f, 90f, 200f, 50f), "删除动作组件")) { bool isOk = EditorUtility.DisplayDialog("删除动作组件", "警告:不可逆过程,需要通过svn才能还原!确定要删除所有动作组件吗", "确定", "取消"); if (isOk) { VisualAutuPack.DelAnimationComponent(); } } if (GUI.Button(new Rect(300f, 160f, 200f, 50f), "一键所有动作组件bundle")) { VisualAutuPack.ExecuteAnim(buildTarget); } if (GUI.Button(new Rect(40f, 160f, 200f, 50f), "资源加密")) { CreateAssetBundle.ExecuteEncryption(buildTarget); } if (GUI.Button(new Rect(40f, 230f, 200f, 50f), "生成 MD5")) { CreateMD5List.Execute(buildTarget); EditorUtility.DisplayDialog("", "MD5 生成OK", "OK"); } }
public static void ExecuteScene(UnityEditor.BuildTarget target) { //清空一下缓存 Caching.CleanCache(); string SavePath = AssetBundleController.GetPlatformPath(target); string exportPath = SavePath + "Scene/"; if (Directory.Exists(exportPath) == false) { Directory.CreateDirectory(exportPath); } string currentScene = EditorApplication.currentScene; string currentSceneName = currentScene.Substring(currentScene.LastIndexOf('/') + 1, currentScene.LastIndexOf('.') - currentScene.LastIndexOf('/') - 1); string fileName = exportPath + currentSceneName + ".unity3d"; BuildPipeline.BuildStreamedSceneAssetBundle(new string[1] { EditorApplication.currentScene }, fileName, target); AssetDatabase.Refresh(); }
public static void Execute(UnityEditor.BuildTarget target) { // if (AssetBundleController.CheckPlatform(target) == false) // return; string SavePath = AssetBundleController.GetPlatformPath(target); // 当前选中的资源列表 foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets)) { string path = AssetDatabase.GetAssetPath(o); // 过滤掉meta文件和文件夹 if (path.Contains(".meta") || path.Contains(".") == false) { continue; } // 过滤掉UIAtlas目录下的贴图和材质(UI/Common目录下的所有资源都是UIAtlas) if (path.Contains("UI/Common")) { if ((o is Texture) || (o is Material)) { continue; } } path = SavePath + o.name; //path = path.Substring(SavePath.Length, path.Length - path.LastIndexOf('.') - 1); path += ".assetbundle"; BuildPipeline.BuildAssetBundle(o, null, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, target); } AssetDatabase.Refresh(); }