Skip to content

Adding support for new Unreal classes

EliotVU edited this page Dec 15, 2014 · 7 revisions

New classes can be registered using either the UnrealPackage method RegisterClass or the attribute UnrealRegisterClass if the class resides in the UELib itself.

RegisterClass

With the RegisterClass method you can register new classes dynamically at runtime but requires more effort to setup and maintain.

public class UMyNewClassName : UObject
{
	
}

var package = UnrealLoader.LoadPackage( "FilePathToUPK", System.IO.FileAccess.Read );
if( package != null )
{
    package.RegisterClass( "UTexture", typeof(UMyNewClassName) );
    package.InitializePackage();
}

Whenever an object of class type UTexture, a new instance of class UMyNewClassName will be created.

UnrealRegisterClass

Registering classes is a lot easier with the UnrealRegisterClass attribute, but be aware that the library only scans for this attribute on classes that reside in the Eliot.UELib.dll.

[UnrealRegisterClass]
public class UTexture : UObject
{

}

Whenever an object of class type UTexture, a new instance of class UTexture will be created.
Clone this wiki locally