public virtual bool VersionExists() { BundleBuilder builder = new BundleBuilder(); string versionOutput = builder.GetVersionOutput(this.OutputPath, this.BuildTarget, this.DataVersion); return(Directory.Exists(versionOutput)); }
public virtual void CopyToStreamingAssets() { try { AssetDatabase.StartAssetEditing(); BundleBuilder builder = new BundleBuilder(); DirectoryInfo src = new DirectoryInfo(builder.GetVersionOutput(this.OutputPath, this.BuildTarget, this.DataVersion)); DirectoryInfo dest = new DirectoryInfo(BundleUtil.GetReadOnlyDirectory()); if (dest.Exists) { dest.Delete(true); } if (!dest.Exists) { dest.Create(); } BundleManifest manifest = builder.CopyAssetBundleAndManifest(src, dest); if (manifest != null) { Debug.LogFormat("Copy AssetBundles success."); } AssetDatabase.Refresh(); } catch (Exception e) { Debug.LogFormat("Copy AssetBundles failure. Error:{0}", e); } finally { AssetDatabase.StopAssetEditing(); } }
public virtual void Build(bool forceRebuild) { string path = this.OutputPath; if (string.IsNullOrEmpty(path)) { BrowseOutputFolder(); } if (string.IsNullOrEmpty(path)) { Debug.LogError("AssetBundle Build: No valid output path for build."); return; } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } BuildAssetBundleOptions options = BuildAssetBundleOptions.DeterministicAssetBundle; switch (this.Compression) { case CompressOptions.Uncompressed: options |= BuildAssetBundleOptions.UncompressedAssetBundle; break; case CompressOptions.ChunkBasedCompression: options |= BuildAssetBundleOptions.ChunkBasedCompression; break; } if (forceRebuild) { options |= BuildAssetBundleOptions.ForceRebuildAssetBundle; } options |= this.BuildAssetBundleOptions; List <IBundleModifier> bundleModifierChain = this.CreateBundleModifierChain(); BundleBuilder builder = new BundleBuilder(); builder.Build(path, this.BuildTarget, options, this.DataVersion, bundleModifierChain); #if UNITY_5_6_OR_NEWER if ((options & BuildAssetBundleOptions.DryRunBuild) > 0) { Debug.LogFormat("Dry Build OK."); return; } #endif DirectoryInfo dir = new DirectoryInfo(builder.GetPlatformOutput(path, this.BuildTarget)); try { //open the folder EditorUtility.OpenWithDefaultApp(dir.FullName); } catch (Exception) { } Debug.LogFormat("Build OK.Please check the folder:{0}", dir.FullName); if (!this.CopyToStreaming) { return; } this.CopyToStreamingAssets(); }