### Plugin Initialization Example Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md An example implementation of the UABEAPlugin interface. This shows how to return plugin metadata, including its name and supported action options. ```csharp public class MyAssetPlugin : UABEAPlugin { public PluginInfo Init() { return new PluginInfo { name = "My Asset Editor", options = new List { new MyAssetOption() } }; } } ``` -------------------------------- ### Example config.json Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/configuration.md Illustrates the structure and possible values for the UABEA configuration file. ```json { "UseDarkTheme": true, "UseCpp2Il": true } ``` -------------------------------- ### Writing an EMIP File Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/emip-format.md Example of creating and writing an InstallerPackageFile to an EMIP file. This method is suitable for creating new mod packages. ```csharp var pkg = new InstallerPackageFile { magic = "EMIP", includesCldb = false, modName = "My Mod", modCreators = "Modder Name", modDescription = "A great mod", addedTypes = null, affectedFiles = new List { new InstallerPackageAssetsDesc { isBundle = true, path = "assets/bundle.dat", replacers = new List { /* replacers */ } } } }; using (var file = File.Create("mymod.emip")) using (var writer = new AssetsFileWriter(file)) { pkg.Write(writer); } ``` -------------------------------- ### Backup Sequence Example Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/command-line.md Illustrates how the `applyemip` command creates incremental backups. It shows the original file and how it's replaced by backup files with incrementing numbers. ```text Original file: assets.dat 1st install: → assets.dat.bak0000, assets.dat.mod → assets.dat 2nd install: → assets.dat.bak0001, assets.dat.mod → assets.dat ``` -------------------------------- ### Create an Installable Mod Package (EMIP) Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/README.md This C# code demonstrates how to create an EMIP package for distributing mods. It defines mod metadata and lists the assets to be included. The generated .emip file can be installed using the UABEAvalonia CLI. ```csharp // Create EMIP package var pkg = new InstallerPackageFile { magic = "EMIP", modName = "My Mod", modCreators = "Modder", modDescription = "Does something cool", includesCldb = false, addedTypes = null, affectedFiles = new List { new InstallerPackageAssetsDesc { isBundle = true, path = "assets/bundle.dat", replacers = new List { /* your replacers */ } } } }; // Write EMIP file using (var file = File.Create("mymod.emip")) using (var writer = new AssetsFileWriter(file)) { pkg.Write(writer); } // User installs with: // dotnet UABEAvalonia.dll applyemip mymod.emip "C:/Games/MyGame" ``` -------------------------------- ### Execute Plugin Action Example Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Example implementation of ExecutePlugin to export a selected texture as PNG. It handles asset export, displays a save dialog, and writes the file. Includes error handling. ```csharp public async Task ExecutePlugin(Window win, AssetWorkspace workspace, List selection) { try { var container = selection[0]; var valueField = workspace.GetBaseField(container); // Process the asset byte[] exported = ExportTexture(valueField); // Show save dialog var topLevel = TopLevel.GetTopLevel(win); var file = await topLevel.StorageProvider.SaveFileAsync( new FilePickerSaveOptions { }); if (file != null) { using (var stream = await file.OpenWriteAsync()) stream.Write(exported, 0, exported.Length); } return true; } catch (Exception ex) { MessageBoxUtil.ShowError("Export failed", ex.Message); return false; } } ``` -------------------------------- ### Reading an EMIP File Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/emip-format.md Example of reading an InstallerPackageFile from an EMIP file. This method is used to load existing mod packages and verify their integrity. ```csharp var pkg = new InstallerPackageFile(); using (var file = File.OpenRead("mymod.emip")) using (var reader = new AssetsFileReader(file)) { bool success = pkg.Read(reader, prefReplacersInMemory: false); if (!success) { Console.WriteLine("Invalid EMIP file"); return; } Console.WriteLine($"Mod: {pkg.modName}"); Console.WriteLine($"By: {pkg.modCreators}"); Console.WriteLine($"Desc: {pkg.modDescription}"); Console.WriteLine($"Files: {pkg.affectedFiles.Count}"); } ``` -------------------------------- ### Bundle Workspace Usage Example Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/bundle-workspace.md Demonstrates loading a bundle, iterating through entries, modifying files by adding or replacing them, marking entries for deletion, and generating replacers for saving the modified bundle. ```csharp var bundleWorkspace = new BundleWorkspace(); bundleWorkspace.Reset(bundleFileInstance); foreach (var item in bundleWorkspace.Files) { Console.WriteLine($"{item.Name} ({item.Size} bytes)"); } using (var newData = File.OpenRead("updated_assets.dat")) { bundleWorkspace.AddOrReplaceFile(newData, "assets", true); } var item = bundleWorkspace.FileLookup["old_assets"]; item.IsRemoved = true; var replacers = bundleWorkspace.GetReplacers(); using (var output = File.Create("modified.bundle")) { using (var writer = new AssetsFileWriter(output)) { bundleFileInstance.file.Write(writer, replacers); } } ``` -------------------------------- ### Filter Assets by Type Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-container.md Use this pattern to retrieve all assets of a specific type from the workspace. The example shows how to get all meshes and print their PathIds. ```csharp // Get all assets of a specific type var meshes = workspace.GetAssetsOfType(AssetClassID.Mesh); foreach (var container in meshes) { Console.WriteLine($"Mesh PathId: {container.PathId}"); } ``` -------------------------------- ### Extensibility - UABEAPlugin Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/INDEX.md The UABEAPlugin interface serves as the entry point for plugins. It works in conjunction with the UABEAPluginOption interface for action handling. The PluginManager class is responsible for plugin loading and filtering. Key enums and classes include UABEAPluginAction, PluginInfo, UABEAPluginMenuInfo, and a complete example plugin implementation is provided. ```APIDOC ## UABEAPlugin Interface ### Description Plugin entry point. ### UABEAPluginOption Interface - Action handler. ### PluginManager Class - Plugin loading and filtering. ### UABEAPluginAction Enum - Import - Export - Console - Create ### Other Classes - `PluginInfo` - `UABEAPluginMenuInfo` ### Example Complete example plugin implementation. ``` -------------------------------- ### Validate Plugin Selection Example Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Example implementation of SelectionValidForPlugin to check if the action is export and if a single Texture2D asset is selected. The output name is set to 'Export as PNG'. ```csharp public bool SelectionValidForPlugin(AssetsManager am, UABEAPluginAction action, List selection, out string name) { name = ""; // Only support export on single Texture2D if (action != UABEAPluginAction.Export) return false; if (selection.Count != 1) return false; if (selection[0].ClassId != (int)AssetClassID.Texture2D) return false; name = "Export as PNG"; return true; } ``` -------------------------------- ### Initialize AssetWorkspace Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Initializes a new AssetWorkspace instance. Use this to start managing asset files in memory. The 'fromBundle' parameter specifies if assets are loaded from a bundle. ```csharp AssetsManager am = new AssetsManager(); AssetWorkspace workspace = new AssetWorkspace(am, false); ``` -------------------------------- ### Texture Export Plugin Example Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md This C# code defines a plugin for UABEAPlugin that exports textures. It includes methods for plugin initialization, selection validation, and the execution of the export process. Ensure the necessary UABEAvalonia and AssetsTools.NET namespaces are included. ```csharp using UABEAvalonia; using UABEAvalonia.Plugins; using AssetsTools.NET; using AssetsTools.NET.Extra; public class TextureExportPlugin : UABEAPlugin { public PluginInfo Init() { return new PluginInfo { name = "Texture Tools", options = new List { new TextureExporter() } }; } } public class TextureExporter : UABEAPluginOption { public bool SelectionValidForPlugin(AssetsManager am, UABEAPluginAction action, List selection, out string name) { name = ""; if (action != UABEAPluginAction.Export || selection.Count != 1) return false; if (selection[0].ClassId != (int)AssetClassID.Texture2D) return false; name = "Export as PNG"; return true; } public async Task ExecutePlugin(Window win, AssetWorkspace workspace, List selection) { try { var container = selection[0]; var field = workspace.GetBaseField(container); // Export logic here var pngData = ConvertTextureToPng(field); // Save with file dialog return await ShowSaveDialog(win, pngData); } catch { return false; } } private byte[] ConvertTextureToPng(AssetTypeValueField field) { // Implementation details... return new byte[0]; } private async Task ShowSaveDialog(Window win, byte[] data) { // Implementation details... return true; } } ``` -------------------------------- ### Format Specifications - EMIP Format Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/INDEX.md The EMIP format specification details the structure of EMIP mod packages using the InstallerPackageFile class. It outlines the binary format with offsets and sizes, including header, type definitions, affected files, and replacer objects. Encoding for BundleReplacer vs AssetsReplacer and fields for Hash128 and metadata are covered, along with read/write examples. ```APIDOC ## EMIP Format Specification ### InstallerPackageFile Class - EMIP mod package structure. ### Binary Format - Specification with offsets and sizes. - Header, type definitions, affected files, replacer objects. - BundleReplacer vs AssetsReplacer encoding. - Hash128 and metadata fields. ### Examples - Read/Write examples. ``` -------------------------------- ### Navigate from PPtr Field Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-container.md Use this pattern to start with a PPtr field from a deserialized asset and resolve the corresponding AssetContainer. This involves extracting file and path IDs to locate the asset. ```csharp // Start with a PPtr field from a deserialized asset AssetTypeValueField pptrField = parent["m_Material"]; // points to Material // Extract file/path IDs int fileId = pptrField["m_FileID"].AsInt; long pathId = pptrField["m_PathID"].AsLong; // Resolve the container var materialContainer = workspace.GetAssetContainer(fileInst, fileId, pathId, onlyInfo: false); if (materialContainer?.HasValueField) { var materialData = materialContainer.BaseValueField; } ``` -------------------------------- ### Get Assets by Class ID (Integer) Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Retrieves a list of all loaded assets that match the specified Unity class ID. Use this to filter assets by their type. ```csharp public List GetAssetsOfType(int classId) ``` -------------------------------- ### UnityContainer: Get Container Path Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/utilities.md Retrieves the display path for an asset pointer. Returns a string representing the path (e.g., "Assets/Prefabs/Player.prefab") or null if the asset is not found. ```csharp public string? GetContainerPath(AssetPPtr assetPPtr) ``` -------------------------------- ### Loading Plugins from Directory Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/configuration.md Shows how to initialize the plugin manager and load all available plugins from a specified directory. ```csharp var manager = new PluginManager(); manager.LoadPluginsInDirectory("./plugins"); ``` -------------------------------- ### Main Entry Point for Command Line - C# Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/command-line.md Serves as the entry point for command-line mode, dispatching operations based on the provided arguments. Ensure arguments are passed correctly to trigger the desired batch operation. ```csharp public static void CLHMain(string[] args) ``` -------------------------------- ### Get Changed Files Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Scans NewAssets and OtherAssetChanges to determine which files require write operations. ```csharp public HashSet GetChangedFiles() ``` -------------------------------- ### PrintHelp() Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/command-line.md Prints the usage information for all available command-line operations to the console. This is useful for understanding the available commands and their arguments. ```APIDOC ## PrintHelp() ### Description Prints usage information for all command-line operations to the console. ### Method `static void` ### Parameters None ### Output Usage information for command-line operations. ``` -------------------------------- ### UABEAPlugin.Init() Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Called once when the plugin DLL is loaded. This method must return a PluginInfo object containing the plugin's name and a list of supported action options. ```APIDOC ## UABEAPlugin.Init() ### Description Called once when the plugin DLL is loaded. Must return a PluginInfo with the plugin name and list of supported options. ### Method Implicit (called by UABEA upon plugin load) ### Parameters None ### Returns `PluginInfo`: Metadata about this plugin and its action options. ### Response Example ```csharp { "name": "My Asset Editor", "options": [ // List of UABEAPluginOption objects ] } ``` ``` -------------------------------- ### Work with New Assets Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-container.md This pattern demonstrates how to create new asset data, serialize it, and prepare it for addition to the workspace. It involves creating an AssetsReplacerFromMemory and an AssetContainer for preview. ```csharp // Create new asset data byte[] assetData = /* serialize data */; var replacer = new AssetsReplacerFromMemory(pathId, classId, monoId, assetData); // Create container for preview var container = new AssetContainer(fileReader, position, pathId, classId, monoId, (uint)assetData.Length, fileInst); // Add to workspace workspace.AddReplacer(fileInst, replacer); ``` -------------------------------- ### Get Assets by Class ID (Enum) Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Retrieves a list of all loaded assets that match the specified AssetClassID enum. This is a type-safe way to filter assets. ```csharp var gameObjects = workspace.GetAssetsOfType(AssetClassID.GameObject); ``` -------------------------------- ### Get Asset Container from PPtr Field Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Extracts fileId and pathId from a PPtr field and resolves the asset. Use this for convenience when navigating PPtr fields. ```csharp var scriptField = container.BaseValueField["m_Script"]; var scriptContainer = workspace.GetAssetContainer(fileInst, scriptField); ``` -------------------------------- ### Get Base Field from PPtr Field Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Retrieves the fully deserialized value field from a PPtr field. This method simplifies accessing nested asset data. ```csharp public AssetTypeValueField? GetBaseField(AssetsFileInstance fileInst, AssetTypeValueField pptrField) ``` -------------------------------- ### Accessing Configuration Settings in C# Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/configuration.md Demonstrates how to read, modify, and explicitly save configuration settings within the application. ```csharp // Read settings if (ConfigurationManager.Settings.UseDarkTheme) { // Apply dark theme } // Modify settings (auto-saves) ConfigurationManager.Settings.UseCpp2Il = false; // Force save ConfigurationManager.SaveConfig(); ``` -------------------------------- ### Get Base Field from Asset Container Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Retrieves the fully deserialized value field for a given asset container. Returns null if resolution or deserialization fails. ```csharp public AssetTypeValueField? GetBaseField(AssetContainer cont) ``` -------------------------------- ### LoadPluginsInDirectory Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Creates the directory if it doesn't exist, then loads all DLLs in it. Silently skips any that fail to load. ```APIDOC ## LoadPluginsInDirectory(string directory) ### Description Creates the directory if it doesn't exist, then loads all DLLs in it. Silently skips any that fail to load. ### Method ```csharp public void LoadPluginsInDirectory(string directory) ``` ### Parameters #### Path Parameters - **directory** (string) - Yes - Directory containing *.dll files ### Example ```csharp manager.LoadPluginsInDirectory("./plugins"); ``` ``` -------------------------------- ### Get Concatenated Mono Base Field Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Deserializes a MonoBehaviour using both serialized template and live MonoCecil reflection. Attempts to enhance templates with actual assembly metadata. ```csharp public AssetTypeValueField GetConcatMonoBaseField(AssetContainer cont, string managedPath) ``` -------------------------------- ### Print Help Information - C# Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/command-line.md Prints usage information for all command-line operations to the console. Call this method to display available commands and their arguments. ```csharp public static void PrintHelp() ``` -------------------------------- ### LoadPlugin Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Loads a single DLL, reflects for UABEAPlugin implementations, and calls Init(). Returns false on any error (file not found, instantiation failure, exception). ```APIDOC ## LoadPlugin(string path) ### Description Loads a single DLL, reflects for UABEAPlugin implementations, and calls Init(). Returns false on any error (file not found, instantiation failure, exception). ### Method ```csharp public bool LoadPlugin(string path) ``` ### Parameters #### Path Parameters - **path** (string) - Yes - Path to DLL file ### Returns `bool`: True if plugin loaded and initialized successfully. ### Example ```csharp var manager = new PluginManager(); bool success = manager.LoadPlugin("path/to/MyPlugin.dll"); ``` ``` -------------------------------- ### UnityContainer: Try Get Resource Manager Container Base Field Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/utilities.md Static helper to locate the ResourceManager in globalgamemanagers, with a fallback to mainData. Returns false if the resource manager is not found. ```csharp public static bool TryGetRsrcManContainerBaseField( AssetWorkspace workspace, AssetsFileInstance file, [MaybeNullWhen(false)] out AssetsFileInstance actualFile, [MaybeNullWhen(false)] out AssetTypeValueField baseField) ``` -------------------------------- ### Command-Line Operations - CommandLineHandler Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/INDEX.md The CommandLineHandler class is the entry point for command-line operations. It supports commands such as `batchexportbundle`, `batchimportbundle`, and `applyemip`. Various flags like `-keepnames`, `-kd`, `-fd`, and `-md` are available for decompression options. The documentation also covers the backup strategy and error handling. ```APIDOC ## CommandLineHandler ### Description Command-line interface entry point. ### Commands - `batchexportbundle`: Extract all assets from bundles. - `batchimportbundle`: Re-import modified assets. - `applyemip`: Install mod packages. ### Flags - `-keepnames`: Keep original asset names. - `-kd`: Decompression option. - `-fd`: Decompression option. - `-md`: Decompression option. ### Other - Backup strategy. - Error handling. ``` -------------------------------- ### Utilities & Helpers Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/INDEX.md This section details various utility classes and helpers. It includes FileTypeDetector for identifying file types, PathUtils for path manipulation, SearchUtils for wildcard pattern matching, AssetBundleUtil for compression detection, ConfigurationManager for settings, UnityContainer for resolution, and UnityContainerAssetInfo for container metadata. ```APIDOC ## Utilities & Helpers ### FileTypeDetector - Identify file types (Bundle vs Assets). ### PathUtils - Path manipulation and game directory resolution. ### SearchUtils - Wildcard pattern matching. ### AssetBundleUtil - Compression detection. ### ConfigurationManager - Settings management. ### UnityContainer - AssetBundle/ResourceManager resolution. ### UnityContainerAssetInfo - Container metadata. ``` -------------------------------- ### Initialize BundleWorkspace Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/bundle-workspace.md Initializes an empty BundleWorkspace. Call Reset() to load a bundle. ```csharp public BundleWorkspace() ``` ```csharp var bundleWorkspace = new BundleWorkspace(); bundleWorkspace.Reset(bundleFileInstance); ``` -------------------------------- ### LoadPlugin Method Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Loads a single plugin DLL from the specified path. It reflects for UABEAPlugin implementations and calls Init(). Returns false if any error occurs during loading or initialization. ```csharp public bool LoadPlugin(string path) ``` ```csharp var manager = new PluginManager(); bool success = manager.LoadPlugin("path/to/MyPlugin.dll"); ``` -------------------------------- ### UnityContainer: Try Get Bundle Container Base Field Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/utilities.md Static helper to locate and deserialize the AssetBundle asset within a file. Returns false if the asset is not found or deserialization fails. ```csharp public static bool TryGetBundleContainerBaseField( AssetWorkspace workspace, AssetsFileInstance file, [MaybeNullWhen(false)] out AssetsFileInstance actualFile, [MaybeNullWhen(false)] out AssetTypeValueField baseField) ``` -------------------------------- ### Get Concat Mono Template Field Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Resolves the MonoScript for a MonoBehaviour and attempts to concatenate live type information from the Managed assembly. Falls back to serialized template if assembly not found. ```csharp public AssetTypeTemplateField GetConcatMonoTemplateField(AssetContainer cont, string managedPath) ``` -------------------------------- ### CLHMain(string[]) Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/command-line.md The main entry point for the command-line interface. It parses the provided arguments and dispatches to the appropriate command handler (e.g., batchexportbundle, batchimportbundle, applyemip). ```APIDOC ## CLHMain(string[]) ### Description Entry point for command-line mode. Dispatches to command handlers based on the first argument. ### Method `static void` ### Parameters #### Path Parameters - **args** (string[]) - Required - Command line arguments provided to the application. ### Behavior - If `args.Length < 2`: prints help and returns. - If `args[0] == "batchexportbundle"`: calls `BatchExportBundle`. - If `args[0] == "batchimportbundle"`: calls `BatchImportBundle`. - If `args[0] == "applyemip"`: calls `ApplyEmip`. ### Example ```csharp // In Program.Main() if (args.Length > 0) { CommandLineHandler.CLHMain(args); } ``` ``` -------------------------------- ### Get Asset Template Field Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Retrieves the template field for a given asset container, which is suitable for value deserialization. Options are available to force the use of ClassDatabase or skip MonoBehaviour fields. ```csharp var template = workspace.GetTemplateField(container); var valueField = template.MakeValue(container.FileReader, container.FilePosition); ``` -------------------------------- ### InstallerPackageFile Class Definition Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/emip-format.md Defines the structure of an EMIP package, including metadata, optional type definitions, and a list of affected files. ```csharp public class InstallerPackageFile { public string magic; public bool includesCldb; public string modName; public string modCreators; public string modDescription; public ClassDatabaseFile addedTypes; public List affectedFiles; public bool Read(AssetsFileReader reader, bool prefReplacersInMemory = false) public void Write(AssetsFileWriter writer) } ``` -------------------------------- ### GetPluginsThatSupport Method Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Retrieves a list of menu items for plugins that support the currently selected assets. It iterates through loaded plugins and their options, checking compatibility. ```csharp public List GetPluginsThatSupport(AssetsManager am, List selectedAssets) ``` ```csharp var menuItems = manager.GetPluginsThatSupport(workspace.am, selectedAssets); foreach (var item in menuItems) { Console.WriteLine($"{item.pluginInf.name}: {item.displayName}"); // Show in UI, execute on user click var success = await item.pluginOpt.ExecutePlugin(window, workspace, selectedAssets); } ``` -------------------------------- ### Get Base Field from File Instance and IDs Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Retrieves the fully deserialized value field using the file instance, file ID, and path ID. Useful for direct asset access. ```csharp public AssetTypeValueField? GetBaseField(AssetsFileInstance fileInst, int fileId, long pathId) ``` -------------------------------- ### LoadPluginsInDirectory Method Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Loads all DLL files from the specified directory. It creates the directory if it does not exist and silently skips any DLLs that fail to load. ```csharp public void LoadPluginsInDirectory(string directory) ``` ```csharp manager.LoadPluginsInDirectory("./plugins"); ``` -------------------------------- ### Get BundleReplacers Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/bundle-workspace.md Generates a list of BundleReplacer objects required to save all modifications made to the bundle. This includes BundleRemover for entries marked for removal, BundleReplacerFromStream for modified entries, and BundleRenamer for entries that have been renamed but not modified. ```csharp public List GetReplacers() ``` ```csharp var replacers = bundleWorkspace.GetReplacers(); // Pass to BundleFile.Write(writer, replacers) ``` -------------------------------- ### BundleWorkspace Constructor Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/bundle-workspace.md Initializes an empty BundleWorkspace. Use Reset() to load a bundle. ```APIDOC ## BundleWorkspace() ### Description Initializes an empty workspace with no loaded bundle. Call Reset() to load a bundle. ### Example ```csharp var bundleWorkspace = new BundleWorkspace(); bundleWorkspace.Reset(bundleFileInstance); ``` ``` -------------------------------- ### Get Assets File Directory Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/utilities.md Resolves the game directory for an assets file instance. This method handles special cases like Addressables and builtin resources to correctly identify the game's root directory. ```csharp public static string GetAssetsFileDirectory(AssetsFileInstance fileInst) ``` ```csharp string gameDir = PathUtils.GetAssetsFileDirectory(fileInst); // Now can find Managed/, globalgamemanagers, etc. ``` -------------------------------- ### Get File Path Without Extension Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/utilities.md This utility method removes the file extension from a given path while keeping the directory structure intact. It's useful when you need to refer to a file by its base name and directory. ```csharp public static string GetFilePathWithoutExtension(string path) ``` ```csharp var result = PathUtils.GetFilePathWithoutExtension("C:/Assets/myfile.dat"); // Result: "C:/Assets/myfile" ``` -------------------------------- ### PluginInfo Class Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/types.md Contains metadata for a plugin, including its display name and supported options. Returned by UABEAPlugin.Init(). ```csharp public class PluginInfo { public string name; public List options; } ``` -------------------------------- ### Get Asset Container with Value Field Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Resolves external file references and returns the asset container. If onlyInfo is false, it attempts to deserialize the asset's value field. This may trigger a MonoTemplateLoadFailed event if template generation fails. ```csharp var container = workspace.GetAssetContainer(fileInst, 0, pathId, onlyInfo: false); if (container != null && container.HasValueField) { var field = container.BaseValueField; } ``` -------------------------------- ### Import Raw Asset from File Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-import-export.md Reads all bytes from a file into memory for binary asset import without parsing. Used to create an asset replacer. ```csharp using (var file = File.OpenRead("asset.bin")) { byte[] data = exporter.ImportRawAsset(file); var replacer = AssetImportExport.CreateAssetReplacer(container, data); } ``` -------------------------------- ### ConfigurationManager.Settings Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/utilities.md Access the static instance of application settings. This instance is loaded from `config.json` on first access and is created with default values if the file does not exist. ```APIDOC ## ConfigurationManager.Settings ### Description Static instance of application settings, loaded from `config.json` on first access. Created with defaults if file doesn't exist. ### Type ConfigurationSettings ### Example ```csharp if (ConfigurationManager.Settings.UseDarkTheme) { // Apply dark theme } ``` ``` -------------------------------- ### UABEAPluginMenuInfo Class Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/types.md Holds information for displaying a plugin option in a menu. Includes parent plugin details and display text. ```csharp public class UABEAPluginMenuInfo { public readonly PluginInfo pluginInf; public readonly UABEAPluginOption pluginOpt; public readonly string displayName; } ``` -------------------------------- ### InstallerPackageAssetsDesc Class Definition Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/emip-format.md Defines the structure for describing assets within an EMIP package, including whether it's a bundle, its relative path, and associated replacers. ```csharp public class InstallerPackageAssetsDesc { public bool isBundle; // Is this a bundle file? public string path; // Relative path from game root public List replacers; // AssetsReplacer or BundleReplacer objects } ``` -------------------------------- ### Add or Replace File in BundleWorkspace Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/bundle-workspace.md Adds a new entry to the workspace or replaces an existing one. If 'prevName' is provided and matches an existing entry, that entry is replaced. Otherwise, a new entry is added. The method handles stream management to prevent leaks, closing old streams only if they were newly imported. ```csharp public void AddOrReplaceFile(Stream stream, string name, bool isSerialized, string? prevName = null) ``` ```csharp // Import new entry using (var fileStream = File.OpenRead("new_assets.dat")) { bundleWorkspace.AddOrReplaceFile(fileStream, "new_assets.dat", true); } // Replace existing entry with same name using (var fileStream = File.OpenRead("modified.dat")) { bundleWorkspace.AddOrReplaceFile(fileStream, "assets", true, "assets"); } ``` -------------------------------- ### Reset Method Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/bundle-workspace.md Loads or clears the bundle file in the workspace. Populates entries and clears pending modifications. ```APIDOC ## Reset(BundleFileInstance? bundleInst) ### Description Loads or clears the bundle. If bundleInst is provided, populates Files with all entries from BlockAndDirInfo.DirectoryInfos. Clears all pending modifications. Can be called multiple times to switch bundles. ### Parameters #### Path Parameters - **bundleInst** (BundleFileInstance?) - Required - Bundle file to load, or null to clear workspace ### Example ```csharp bundleWorkspace.Reset(newBundleInstance); // Files now contains all entries from the bundle ``` ``` -------------------------------- ### Create AssetContainer for New Asset Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-container.md Use this constructor when creating a new asset or a replacement for an existing one. It requires detailed information about the asset's position, identity, and size within the file. ```csharp public AssetContainer(AssetsFileReader fileReader, long assetPosition, long pathId, int classId, ushort monoId, uint size, AssetsFileInstance fileInst, AssetTypeValueField? baseField = null) ``` ```csharp var container = new AssetContainer(reader, position, pathId, classId, monoId, size, fileInst); ``` -------------------------------- ### UABEAPlugin Interface Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/MANIFEST.txt Defines the entry point for plugins in UABEA. Plugins can be developed to extend the functionality of the editor, such as custom import/export operations. ```APIDOC ## UABEAPlugin ### Description Interface for UABEA plugins, defining the entry point for custom functionality. ### Methods - **Initialize(object host)**: Initializes the plugin with the host application. - **GetPluginMenuInfo()**: Returns information about the plugin's menu entries. ``` -------------------------------- ### PluginManager Constructor Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Initializes an empty plugin manager. Plugins should be loaded using LoadPlugin or LoadPluginsInDirectory after initialization. ```csharp public PluginManager() ``` -------------------------------- ### PluginInfo Class Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md A metadata container returned by UABEAPlugin.Init(). It holds the plugin's display name and a list of supported action options for specific asset types. ```APIDOC ## PluginInfo Class ### Description Metadata container returned by UABEAPlugin.Init(). Each option represents an action (import, export, etc.) for specific asset types. ### Fields - **name** (string) - Required - Display name of plugin - **options** (List) - Required - List of action options this plugin supports ``` -------------------------------- ### Set Mono Temp Generators Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Initializes MonoBehaviour template generators (Cpp2IL or MonoCecil) if found. Searches for Cpp2IL output first, then falls back to Managed directory. Only runs once per workspace. ```csharp public bool SetMonoTempGenerators(string fileDir) ``` ```csharp string gameDir = Path.GetDirectoryName(filePath); bool success = workspace.SetMonoTempGenerators(gameDir); ``` -------------------------------- ### BundleWorkspaceItem Constructor Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/bundle-workspace.md Initializes a new instance of the BundleWorkspaceItem class with essential properties. ```csharp public BundleWorkspaceItem(string name, string originalName, bool isNew, bool isSerialized, bool isModified, Stream stream) ``` -------------------------------- ### Load Assets File into Workspace Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Loads an assets file into the workspace. Optionally loads dependency files recursively. Skips files that have already been loaded. ```csharp AssetsFileInstance inst = am.LoadAssetsFile("path/to/assets.dat", true); workspace.LoadAssetsFile(inst, loadDependencies: true); ``` -------------------------------- ### Utilities Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/MANIFEST.txt Provides various utility classes for common tasks such as file type detection, path manipulation, wildcard matching, bundle analysis, settings management, and asset resolution. ```APIDOC ## Utilities ### FileTypeDetector Detects the type of a given file. ### PathUtils Provides methods for manipulating file paths. ### SearchUtils Handles wildcard matching for searching files. ### AssetBundleUtil Analyzes Unity asset bundles. ### ConfigurationManager Manages application configuration settings. ### UnityContainer Resolves Unity assets within containers. ### UnityContainerAssetInfo Stores metadata for assets within a Unity container. ``` -------------------------------- ### Import Text Asset from StreamReader Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-import-export.md Parses UABE dump format text from a StreamReader and serializes it to binary. Use this when you have asset data in the UABE text dump format. ```csharp public byte[]? ImportTextAsset(StreamReader sr, out string? exceptionMessage) ``` ```csharp using (var file = File.OpenText("asset.txt")) { byte[] assetData = exporter.ImportTextAsset(file, out string? error); if (assetData == null) { Console.WriteLine($"Parse error: {error}"); } else { var replacer = AssetImportExport.CreateAssetReplacer(container, assetData); } } ``` -------------------------------- ### Dump Raw Asset to File Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-import-export.md Copies raw asset bytes from a reader to an output file stream without processing. Reads in 4KB chunks for efficiency with large assets. ```csharp var exporter = new AssetImportExport(); using (var outFile = File.Create("asset.bin")) { exporter.DumpRawAsset(outFile, reader, position, size); } ``` -------------------------------- ### Batch Export Assets from Bundles Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/README.md Execute this command-line instruction to export all assets from Unity asset bundles located in a specified directory. This process generates individual .dat files for each extracted asset. ```bash # Export all assets from bundles in directory dotnet UABEAvalonia.dll batchexportbundle ./bundles -kd # This creates: bundle.dat_assets0.dat, bundle.dat_assets1.dat, etc. ``` -------------------------------- ### Accessing Configuration Settings Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/utilities.md Check if the dark theme is enabled in the application settings. This accesses the static Settings instance which is loaded on first use. ```csharp if (ConfigurationManager.Settings.UseDarkTheme) { // Apply dark theme } ``` -------------------------------- ### LoadAssetsFile Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Loads assets from a specified file instance into workspace dictionaries. It can optionally load dependency files recursively and skips already loaded files. ```APIDOC ## LoadAssetsFile(AssetsFileInstance, bool) ### Description Loads all assets from the file into workspace dictionaries. If dependencies are enabled, recursively loads all external file dependencies. Skips files already loaded. ### Method `public void LoadAssetsFile(AssetsFileInstance fromFile, bool loadDependencies)` ### Parameters #### Path Parameters - **fromFile** (AssetsFileInstance) - Required - Assets file instance to load - **loadDependencies** (bool) - Required - Whether to recursively load dependency files ### Request Example ```csharp AssetsFileInstance inst = am.LoadAssetsFile("path/to/assets.dat", true); workspace.LoadAssetsFile(inst, loadDependencies: true); ``` ``` -------------------------------- ### Import Modified Text Dump Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/README.md Imports asset data from a text file and creates a replacer for the workspace. This allows modified asset data to be applied back to the workspace. ```csharp var exporter = new AssetImportExport(); using (var file = File.OpenText("asset.txt")) { byte[] data = exporter.ImportTextAsset(file, out string error); if (data != null) { var replacer = AssetImportExport.CreateAssetReplacer(container, data); workspace.AddReplacer(fileInst, replacer); } } ``` -------------------------------- ### Program Main Method Integration - C# Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/command-line.md Integrates the CommandLineHandler.CLHMain method into the Program.Main entry point to enable command-line functionality. This allows the application to process arguments when run from the command line. ```csharp // In Program.Main() if (args.Length > 0) { CommandLineHandler.CLHMain(args); } ``` -------------------------------- ### UABEAPluginOption Interface Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/types.md The UABEAPluginOption interface defines methods for handling plugin-specific options, validating asset selections, and executing plugin logic. ```APIDOC ## Interface UABEAPluginOption ### Description Defines methods for managing plugin options, validating asset selections, and executing plugin actions. ### Methods #### SelectionValidForPlugin(AssetsManager am, UABEAPluginAction action, List selection, out string name) - **Description**: Checks if the current asset selection is valid for this plugin option. - **Parameters**: - `am` (AssetsManager) - The asset manager instance. - `action` (UABEAPluginAction) - The action context. - `selection` (List) - The list of selected assets. - `name` (out string) - Output parameter for the name of the option if valid. - **Return Type**: `bool` - True if the selection is valid, false otherwise. #### ExecutePlugin(Window win, AssetWorkspace workspace, List selection) - **Description**: Asynchronously executes the plugin's logic with the given parameters. Can perform I/O and display dialogs. - **Parameters**: - `win` (Window) - The main window context. - `workspace` (AssetWorkspace) - The current asset workspace. - `selection` (List) - The list of selected assets. - **Return Type**: `Task` - A task that returns true on success, false on error. ``` -------------------------------- ### Type Definitions Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/INDEX.md This section provides a comprehensive reference for all enums, delegates, structs, classes, and interfaces used within UABEA. It includes quick reference tables for enums like DetectedFileType and UABEAPluginAction, delegates, structs such as AssetID and AssetPPtr, classes like PluginInfo and BundleWorkspaceItem, and interfaces like UABEAPlugin. ```APIDOC ## Type Definitions ### Enums - `DetectedFileType` - `UABEAPluginAction` - `AssetsFileChangeTypes` ### Delegates - `AssetWorkspaceItemUpdateEvent` - `MonoTemplateFailureEvent` ### Structs - `AssetID` (deprecated) - `AssetPPtr` ### Classes - `PluginInfo` - `ConfigurationSettings` - `UnityContainerAssetInfo` - `BundleWorkspaceItem` ### Interfaces - `UABEAPlugin` - `UABEAPluginOption` ### Format - Quick reference table format. ``` -------------------------------- ### Create AssetContainer for Existing Asset Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-container.md Use this constructor to create a container for an asset that already exists in an assets file. It extracts metadata from the provided AssetFileInfo. ```csharp public AssetContainer(AssetFileInfo info, AssetsFileInstance fileInst, AssetTypeValueField? baseField = null) ``` ```csharp var container = new AssetContainer(assetInfo, fileInstance); ``` -------------------------------- ### Bundle Management - BundleWorkspace Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/INDEX.md The BundleWorkspace class is used to manage entries within a bundle. It offers methods to reset the workspace, add or replace files, rename files, and retrieve replacers. It also defines the BundleWorkspaceItem class for entry metadata and change tracking, along with a state tracking table for New, Modified, and Removed flags. ```APIDOC ## BundleWorkspace ### Description Manage bundle entries. ### Methods - `Reset()` - `AddOrReplaceFile(string path, byte[] data)` - `RenameFile(string oldPath, string newPath)` - `GetReplacers()` ### BundleWorkspaceItem - Entry metadata and change tracking. ### State Tracking - New (bool) - Modified (bool) - Removed (bool) ``` -------------------------------- ### PluginManager Constructor Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/plugin-system.md Initializes an empty plugin manager. Plugins can be loaded using the LoadPlugin or LoadPluginsInDirectory methods. ```APIDOC ## PluginManager() ### Description Initializes an empty plugin manager. Load plugins via LoadPlugin or LoadPluginsInDirectory. ### Method ```csharp public PluginManager() ``` ``` -------------------------------- ### Saving Configuration Settings Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/utilities.md Demonstrates how a setting change triggers an automatic save. The SaveConfig() method is called implicitly when properties of ConfigurationManager.Settings are modified. ```csharp ConfigurationManager.Settings.UseDarkTheme = true; // SaveConfig called automatically ``` -------------------------------- ### SetMonoTempGenerators Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/asset-workspace.md Initializes MonoBehaviour template generators (Cpp2IL or MonoCecil) if found. Searches for Cpp2IL output first, then falls back to Managed directory. Only runs once per workspace. ```APIDOC ## SetMonoTempGenerators(string) ### Description Initializes MonoBehaviour template generators (Cpp2IL or MonoCecil) if found. Searches for Cpp2IL output first, then falls back to Managed directory. Only runs once per workspace. ### Parameters #### Path Parameters - **fileDir** (string) - Yes - Directory containing managed assemblies or Cpp2IL output ### Returns `bool`: True if template generator successfully configured. ### Request Example ```csharp string gameDir = Path.GetDirectoryName(filePath); bool success = workspace.SetMonoTempGenerators(gameDir); ``` ``` -------------------------------- ### Batch Export Bundles Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/api-reference/command-line.md Exports all asset files from bundles in a specified directory. Use flags to control naming and temporary file handling. ```bash dotnet UABEAvalonia.dll batchexportbundle ./bundles -kd ``` ```bash dotnet UABEAvalonia.dll batchexportbundle ./bundles -keepnames ``` -------------------------------- ### applyemip Command-Line Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/configuration.md Usage for the applyemip command, specifying flags for handling .decomp files when applying patch files. ```bash UABEAvalonia applyemip [flags] ``` -------------------------------- ### BundleWorkspace Class Source: https://github.com/nesrak1/uabea/blob/master/_autodocs/MANIFEST.txt Manages entries within a bundle file. It allows adding, replacing, and renaming files within the bundle, and retrieving replacers. ```APIDOC ## BundleWorkspace ### Description Manages entries and operations within a bundle file. ### Methods - **AddOrReplaceFile(string path, object data)**: Adds or replaces a file in the bundle. - **RenameFile(string oldPath, string newPath)**: Renames a file within the bundle. - **GetReplacers()**: Retrieves all replacers for the bundle. ```