Hello,
I come here wondering if there’s a way in which one can expose functions declared inside UStructs to the Blueprint Engine without having to declare them separately inside a UBlueprintFunctionLibrary (and/or Another UObject). Essentially, since functions in UStruct cannot be UFunctions, is there another way/trick to expose them? Not looking to expose absolutely every function that I declare in them (since that would clutter the navigation), but some useful functions. For instance, custom “IsValid()” or “GetGlobalTime” etc. I would prefer to avoid having to utilize Custom Thunks for parsing the input UStructs on each individual type of function (since those too have to be declared in different classes, further complicating code-maintenance.
Any cues/clues? Thanks!
No and it convention applied by UE4 that structs are only used to store data structures, it also comes from fact that structures conventionally are statically allocated in the classes unlike UObject which you only deal with pointers created by the object management system.
If you worried, you should maybe look on how FVector and FRotator got implemented, both are not UStructs… but won’t be suppressed if the are hard coded Note that maybe reflection system doesn’t support function in struct, but C++ still does and you can use them. Depending what you trying to do making custom UK2Node might be the way too.
Also explaining what you trying to do might help, for example what oyu consider “Valid” in your struct, since by convention all UStruct structure themselves regardless where they are always valid.
True, but the Exposed section of FVector and Frotator are through Blueprint Function Libraries.
It’s not something death-or-die. I’m doing most of my functionality in C++ and as you said, I can use them freely in c++ declared systems. However, I would like to have some functions exposed, such as check functions that I have declared in said Ustructs. Examples include Request functions, status retrieving functions, and just general execution (Start/stop action) within the said function. I understand that I could do this through custom thunks in Blueprint Function Libraries but I’d have to parse all potentially accepted Ustructs (and I have a decent amount of them) that could accept said function.
I’m looking for implementation similar to how C++ uses Template Functions. For example:
//That this function
template <class T>
static FORCEINLINE T Get_ByStaticName(const TArray<T>& Array, FName Name, bool Safe)
{
int Found = FindByStaticName<T>(Array, Name);
return Get<T>(Array, Found, Safe);
}
//is usable in Blueprints like it is in C++
int FindSkillName(FName SkillName)
{
return UCMAbstractStaticLibrary::FindByStaticName<FMakeSkillEntry>(SkillPool, SkillName);
}
int Find(FName Name)
{
return UCMAbstractStaticLibrary::FindByStaticName<FAppTransformDataLayer>(Layers, Name);
}