/// <summary> /// Adds currently selected assets to target package. /// </summary> /// <exception cref="ArgumentNullException"/> private static void AddSelectedAssets([NotNull] JEMAssetBuilderPackage package) { if (package == null) { throw new ArgumentNullException(nameof(package)); } if (Selection.objects.Length == 0) { EditorUtility.DisplayDialog("Oops.", "To add new assets in to package, first you need to select the assets. (lul)", "Ok!"); return; } foreach (var obj in Selection.objects) { if (package.Exist(obj)) { continue; } package.AddAsset(obj); } }
/// <summary> /// Exports directly target array of objects. /// </summary> /// <exception cref="ArgumentNullException"/> /// <exception cref="InvalidOperationException"/> public static void ExportDirectly([NotNull] string filePath, [NotNull] Object[] objects) { if (filePath == null) { throw new ArgumentNullException(nameof(filePath)); } if (objects == null) { throw new ArgumentNullException(nameof(objects)); } if (objects.Length == 0) { return; } if (string.IsNullOrEmpty(filePath)) { return; } // Try to load configuration first JEMAssetsBuilderConfiguration.Load(); // Create package from received data var package = new JEMAssetBuilderPackage { Name = Path.GetFileName(filePath).Remove(Path.GetFileName(filePath).Length - JEMAssetsBuilderConfiguration.GetExtension().Length, JEMAssetsBuilderConfiguration.GetExtension().Length) }; // Write objects to new package foreach (var obj in objects) { package.AddAsset(obj); } // Export package. ExportPackages(Path.GetDirectoryName(filePath) ?? throw new InvalidOperationException(), new[] { package }); }