Install CUE4Parse via NuGet
masterTo use CUE4Parse in your C# project, add the NuGet package using the dotnet CLI:
dotnet add package CUE4Parserepository·master·Indexed 20 days ago
https://github.com/fabianfg/cue4parseA 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.
To use CUE4Parse in your C# project, add the NuGet package using the dotnet CLI:
dotnet add package CUE4ParseAlternatively, 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 --recursiveTo 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:
{
...
}
}