UAssetAPI Documentation

repository·master·Indexed 19 days ago

https://github.com/atenfyr/uassetapi

A low-level .NET library for reading and writing Unreal Engine game assets (.uasset files), supporting versions ~4.13 to 5.7. It provides tools for property manipulation, JSON serialization, Kismet blueprint bytecode access, and .usmap parsing. The library includes specialized classes such as AssetBinaryReader and AssetBinaryWriter for primitive data, CRCGenerator for name map hashes, and AC7Decrypt for encrypting and decrypting Ace Combat 7 assets.

Tokens
435K
Snippets
1.8K
Records
2.1K
Agent score
61%

What's inside UAssetAPI

  1. Overview of UAssetAPI features

    master

    UAssetAPI provides low-level read/write capabilities for Unreal Engine assets. Key features include:

    • Wide Version Support: Handles cooked and uncooked .uasset files from Unreal Engine versions ~4.13 to 5.7.
    • Extensive Type Support: Supports over 100 property types and 12 export types.
    • Data Interchange: Supports JSON export and import using a proprietary format designed to maintain binary equality.
    • Bytecode Access: Ability to read and write raw Kismet (blueprint) bytecode.
    • Mapping Support: Can read unofficial .usmap files to parse ambiguous or unversioned properties.
    • Resilience: Includes fail-safes for properties and exports that fail serialization.
    • Extensibility: Features automatic reflection for new property types found in other loaded assemblies.
  2. Explore UAssetAPI Class Documentation

    master

    The UAssetAPI class documentation provides a comprehensive reference for the core components used to interact with Unreal Engine assets. The documentation is organized into several functional namespaces:

    • Core API: Fundamental classes like UAsset, MainSerializer, PakReader, and PakWriter for handling asset files and pak archives.
    • Custom Versions: Documentation for various engine-specific versioning structures (e.g., FCoreObjectVersion, FNiagaraObjectVersion).
    • Export Types: Data structures used for exporting asset data (e.g., ClassExport, PropertyExport, DataTableExport).
    • Field Types: Detailed references for property and field types used within assets (e.g., FProperty, UObjectProperty, FArrayProperty).
    • Kismet & Bytecode: Advanced documentation for handling Blueprint serialization and bytecode expressions (e.g., KismetSerializer, KismetExpression).
  3. Use AC7Decrypt to handle Ace Combat 7 assets

    master

    The AC7Decrypt class in the UAssetAPI namespace provides tools to decrypt and encrypt Ace Combat 7 assets. It supports both file-based operations (reading from and writing to disk) and in-memory byte array operations using an AC7XorKey.

    using UAssetAPI;
    
    // Example of initializing the decryptor
    var decryptor = new AC7Decrypt();
  4. Use AssetObjectPropertyData for object references

    master

    In the UAssetAPI.PropertyTypes.Objects namespace, AssetObjectPropertyData describes a reference variable to another object. This reference may be null and can become valid or invalid at any point during the asset lifecycle. It is a near synonym for SoftObjectPropertyData.

    Key characteristics:

    • It implements ICloneable.
    • It is decorated with JsonObjectAttribute.
    • It provides access to the property's Value (as an FString), RawValue (as an object), and PropertyType (as an FString).
    // Example instantiation
    var property = new AssetObjectPropertyData(new FName("MyObjectReference"));
  5. Export assets to JSON for inspection

    master
    Because UAssetAPI is a low-level abstraction of the binary format, complex assets can be difficult to navigate. You can use the .SerializeJSON() method to export the asset to a JSON format. This is highly recommended for learning the asset layout, as the JSON structure closely mirrors how properties and exports are organized within UAssetAPI.
  6. Use FTopLevelAssetPath to represent asset paths

    master

    The FTopLevelAssetPath struct in the UAssetAPI.PropertyTypes.Objects namespace is used to represent a top-level path to an asset within an Unreal Engine package. It consists of two primary fields: PackageName and AssetName.

    Field Behavior based on Unreal Engine Version:

    • PackageName: The name of the package containing the asset (e.g., /Path/To/Package). Note that for Unreal Engine versions earlier than 5.1, this field may be null.
    • AssetName: The name of the asset within the package (e.g., AssetName). Note that for Unreal Engine versions earlier than 5.1, this field contains the full path instead of just the asset name.
    // Example of the struct definition
    public struct FTopLevelAssetPath
    {
        public FName PackageName;
        public FName AssetName;
    }
  7. Understand the PropertyData base class

    master

    In the UAssetAPI.PropertyTypes.Objects namespace, PropertyData is an abstract base class representing a generic Unreal property. It serves as the foundation for all specific property types in the API. It implements ICloneable for deep copying and is decorated with JsonObjectAttribute for serialization.

    Key responsibilities include:

    • Managing property metadata (Name, Type, Ancestry).
    • Handling serialization and deserialization via Read and Write methods.
    • Providing access to the underlying property value through RawValue or typed GetObject<T>() calls.
    // PropertyData is abstract and must be used via its derived types
    // or instantiated via specific constructors if available.
    public abstract class PropertyData : System.ICloneable
  8. Manually read asset data into a UAsset instance

    master

    You can initialize an empty UAsset instance using the parameterless constructor or constructors that only take configuration parameters (like EngineVersion or ObjectVersion). This instance will not contain any data until you manually call the UAsset.Read(AssetBinaryReader, Int32[], Int32[]) method.

    // Create an empty instance
    var asset = new UAsset();
    
    // Later, manually load data into it
    asset.Read(reader, offsetArray, lengthArray);
  9. Reference Unreal Engine Enums in UAssetAPI

    master

    UAssetAPI provides access to a vast collection of Unreal Engine enumeration types (enums) through the uassetapi.unrealtypes.engineenums namespace. These enums are used to define properties, modes, and states for various engine components such as bones, collision, materials, meshes, and cameras.

    When working with UAsset files, you will frequently encounter these enums to interpret data correctly. For example, you might use ECollisionResponse to understand how an object interacts with specific channels, or EMaterialShadingModel to identify how a material is rendered.

    Each enum is documented individually in the API reference. Common categories include:

    • Animation/Skeletal: EBoneRotationSource, EBoneSpaces, EBoneVisibilityStatus.
    • Collision: ECollisionChannel, ECollisionEnabled, ECollisionResponse.
    • Materials: EMaterialDomain, EMaterialShadingModel, EMaterialSamplerType.
    • Rendering/Camera: ECameraProjectionMode, ECameraAlphaBlendMode, EDOFMode.
    • Physics/Constraints: EConstraintFrame, EConstraintTransform.
  10. Use RawExport for unparsed export data

    master

    In UAssetAPI.ExportTypes, the RawExport class serves as a fallback mechanism. When UAssetAPI encounters an export that it cannot properly parse into a structured format, it represents that export as a RawExport object containing the raw byte array. This allows you to still access metadata (like ObjectName and ObjectFlags) even if the internal object data is unreadable by the parser.

    // Example of how a RawExport might be used conceptually when parsing fails
    if (export is RawExport raw)
    {
        byte[] rawData = raw.Data;
        string name = raw.ObjectName.ToString();
        // Handle the unparsed data manually
    }