Using Other Types in UE4 BP
While building out SteamBridge I needed a way to access SteamID
in BP which happens to be a uint64
so I'm not able to directly. Here's the solution I came up with and I must say it's not the most ideal solution as I mainly needed typedef
s, but this works.
USTRUCT(BlueprintType)
struct FUint64
{
GENERATED_BODY()
uint64 Value;
operator uint64() const { return Value; }
FUint64() : Value(0) {}
FUint64(uint64 value) : Value(value) {}
};
USTRUCT(BlueprintType)
struct FMyCoolUint64Type : public FUint64 { GENERATED_BODY() using FUint64::FUint64; };
To avoid writing the same FUint64
struct for all of the types that just need to be a uint64
you can just derive your struct from it and add a using FUint64::FUint64;
so we use it's constructors.
You should also add a method in your class to be able to construct this struct in BP since you can't set the value in BP as it's a type that isn't supported. You can add a method to take a string that's converted to a uint64
to output the FMyCoolUint64Type
.
// psudo-code
UFUNCTION(BlueprintCallable)
void makecoolstruct(const FString& convert, FMyCoolUint64Type& type)
{
type = { FCString::Strtoui64(*convert, NULL, 10) };
// or some conversion from string to type etc
}
until next time