using UnityEngine;using System.Collections;using UnityEditor; /// <summary>/// 简单资源打包Editor/// </summary>public class BuildPacketEditor : EditorWindow { [MenuItem("Tools/Packet/BuildAssetBundle-Android")] public static void ExportAndroid() { ImportPacket(BuildTarget.Android);//打包到安卓资源 } [MenuItem("Tools/Packet/BuildAssetBundle-IOS")] public static void ExportIos() { ImportPacket(BuildTarget.iOS);//打包到IOS资源 } [MenuItem("Tools/Packet/BuildAssetBundle-Win")] public static void ExportWin() { ImportPacket(BuildTarget.StandaloneWindows);//打包到wwindows资源 } static void ImportPacket(BuildTarget target) { string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "assetbundle");//显示“保存文件”对话框并返回所选路径名。 if (path.Length != 0) { Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); if (selection.Length < 1) { Debug.LogError("请选中要打包资源!"); return; } BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, target); } } }
原文地址:https://www.cnblogs.com/yangyadong66/p/9259954.html
时间: 2024-10-09 16:17:39