protected static List <AssetBundleBuild> GetBuildList(EZBundleObject ezBundle) { List <AssetBundleBuild> buildList = new List <AssetBundleBuild>(); foreach (EZBundleObject.BundleInfo ezBundleInfo in ezBundle.bundleList) { if (ezBundleInfo.bundleName == "" || ezBundleInfo.dirPath == "") { continue; } if (ezBundleInfo.filePattern == "") { ezBundleInfo.filePattern = "*.*"; } string[] files = Directory.GetFiles("Assets/" + ezBundleInfo.dirPath, ezBundleInfo.filePattern, ezBundleInfo.searchOption); for (int i = 0; i < files.Length; i++) { files[i] = files[i].Replace('\\', '/'); } AssetBundleBuild build = new AssetBundleBuild(); build.assetBundleName = ezBundleInfo.bundleName + ezBundle.bundleExtension; build.assetNames = files; buildList.Add(build); } return(buildList); }
protected override void OnFocus() { base.OnFocus(); ezBundle = EZScriptableObject.Load <EZBundleObject>(EZBundleObject.AssetName); so_EZBundle = new SerializedObject(ezBundle); bundleTarget = so_EZBundle.FindProperty("bundleTarget"); relativePath = so_EZBundle.FindProperty("relativePath"); removeOldFiles = so_EZBundle.FindProperty("removeOldFiles"); bundleDirPath = so_EZBundle.FindProperty("bundleDirPath"); bundleExtension = so_EZBundle.FindProperty("bundleExtension"); createListFile = so_EZBundle.FindProperty("createListFile"); listFileName = so_EZBundle.FindProperty("listFileName"); copyList = new ReorderableList(so_EZBundle, so_EZBundle.FindProperty("copyList"), true, true, true, true); bundleList = new ReorderableList(so_EZBundle, so_EZBundle.FindProperty("bundleList"), true, true, true, true); copyList.drawHeaderCallback = DrawCopyListHeader; copyList.drawElementCallback = DrawCopyListElement; bundleList.drawHeaderCallback = DrawBundleListHeader; bundleList.drawElementCallback = DrawBundleListElement; }
public static void BuildBundle(EZBundleObject ezBundle) { OnPreBuild(); string bundleDirPath = ezBundle.relativePath ? "Assets/" + ezBundle.bundleDirPath : ezBundle.bundleDirPath; if (!bundleDirPath.EndsWith("/")) { bundleDirPath = bundleDirPath + "/"; } if (ezBundle.removeOldFiles && Directory.Exists(bundleDirPath)) { Directory.Delete(bundleDirPath, true); } Directory.CreateDirectory(bundleDirPath); AssetDatabase.Refresh(); foreach (EZBundleObject.CopyInfo copyInfo in ezBundle.copyList) { if (copyInfo.sourDirPath == "") { continue; } if (copyInfo.filePattern == "") { copyInfo.filePattern = "*.*"; } DirCopy("Assets/" + copyInfo.sourDirPath, "Assets/" + copyInfo.destDirPath + "/" + copyInfo.sourDirPath, copyInfo.filePattern, copyInfo.searchOption); } AssetDatabase.Refresh(); BuildAssetBundleOptions options = BuildAssetBundleOptions.DeterministicAssetBundle; BuildPipeline.BuildAssetBundles(bundleDirPath, GetBuildList(ezBundle).ToArray(), options, ezBundle.bundleTarget); if (ezBundle.createListFile) { CreateFileList(bundleDirPath, ezBundle.listFileName); } AssetDatabase.Refresh(); OnPostBuild(); }
void OnEnable() { saveName = ""; ezBundle = target as EZBundleObject; }