/// <summary> /// Asynchronously builds an AAB at the specified path. /// </summary> /// <param name="aabFilePath">The AAB output file path.</param> /// <param name="assetPackConfig">Asset packs to include in the AAB.</param> /// <param name="onSuccess"> /// Callback that fires with the final aab file location, when the bundle creation succeeds. /// </param> public void CreateBundleAsync(string aabFilePath, AssetPackConfig assetPackConfig, PostBuildCallback onSuccess) { // Copy the AssetPackConfig before leaving the main thread in case the original is modified later. var copiedAssetPackConfig = SerializationHelper.DeepCopy(assetPackConfig); _createBundleAsyncOnSuccess = onSuccess; StartCreateBundleAsync(() => { try { CreateBundle(aabFilePath, copiedAssetPackConfig); } catch (ThreadAbortException ex) { if (!_canceled) { // Unexpected ThreadAbortException. DisplayBuildError("Exception", ex.ToString()); } } catch (Exception ex) { // Catch and display exceptions since they may otherwise be undetected on a background thread. DisplayBuildError("Exception", ex.ToString()); } }); }
/// <summary> /// Asynchronously builds an AAB at the specified path. /// </summary> /// <param name="aabFilePath">Path to the AAB file that should be built.</param> /// <param name="assetPackConfig">Indicates asset packs to include in the AAB.</param> /// <param name="onSuccess"> /// Callback that fires with the final aab file location, when the bundle creation succeeds. /// </param> public void CreateBundleAsync(string aabFilePath, AssetPackConfig assetPackConfig, PostBuildCallback onSuccess) { _progressBarWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); EditorApplication.update += HandleUpdate; _createBundleAsyncOnSuccess = onSuccess; _backgroundThread = new Thread(() => { try { CreateBundle(aabFilePath, assetPackConfig); } catch (Exception ex) { // Catch and display exceptions since they may otherwise be undetected on a background thread. DisplayBuildError("Exception", ex.ToString()); throw; } }); _backgroundThread.Name = "AppBundle"; _backgroundThread.Start(); }