CUE4Parse Documentation

repository·master·Indexed 20 days ago

https://github.com/fabianfg/cue4parse

A C# library for parsing and extracting data from Unreal Engine 4 and 5 archives and packages. It provides support for native data classes including textures, meshes, and animation sequences, and can be installed via NuGet or source.

Tokens
813
Snippets
3
Records
3
Agent score
20%

What's inside CUE4Parse

  1. Install CUE4Parse from source

    master

    Alternatively, you can clone the repository and include it in your project as a project reference. Ensure you use the --recursive flag to include necessary submodules:

    git clone https://github.com/FabianFG/CUE4Parse.git --recursive
  2. Quickstart: Loading and decoding Unreal Engine objects

    master

    To parse Unreal Engine 4 or 5 data, initialize a DefaultFileProvider with your archive directory and the appropriate game version using VersionContainer. You can then load objects using paths to .uasset packages or specific object names within those packages. Once loaded, you can cast objects to specific types like UTexture2D, USoundWave, or UStaticMesh to decode their data.

    var provider = new DefaultFileProvider(ARCHIVE_DIRECTORY_HERE, SearchOption.TopDirectoryOnly, true, new VersionContainer(EGame.GAME_UE4_27));
    provider.Initialize(); // will scan the archive directory for supported file extensions
    
    var allObjects = provider.LoadAllObjects(PACKAGE_PATH_HERE); // {GAME}/Content/Folder1/Folder2/PackageName.uasset
    var fullJson = JsonConvert.SerializeObject(allExports, Formatting.Indented);
    
    var obj = provider.LoadObject(OBJECT_PATH_HERE); // {GAME}/Content/Folder1/Folder2/PackageName.ObjectName
    var objJson = JsonConvert.SerializeObject(objectExport, Formatting.Indented);
    
    switch (obj)
    {
        case UTexture2D texture:
        {
            var bitmap = texture.Decode(ETexturePlatform.DesktopMobile);
            ...
        }
        case USoundWave:
        {
            objectExport.Decode(true, out var audioFormat, out var data);
            ...
        }
        case UStaticMesh:
        case USkeletalMesh:
        case UAnimSequence:
        {
            var toSave = new Exporter(objectExport, EXPORT_OPTIONS_HERE);
            var success = toSave.TryWriteToDir(SAVE_DIRECTORY_INFO_HERE, out var label, out var savedFilePath);
            ...
        }
        default:
        {
            ...
        }
    }