I’m trying to write a blueprint exposed C++ function that takes a UScriptStruct parameter and returns a struct of the corresponding type.
My goal is the write a function that is similar to the Create Actor from Class node. It is my understanding that UScriptStruct is the struct equivalent to UClass. I’ve read how it’s possible to make a function return the same type as a parameter using the metadata specifiers, but I’m trying to return a struct not the same UScriptStruct. Essentially I want to be able to create an instance of the struct corresponding to UScriptStruct and then return it.
Note: I am not taking about the UserDefinedStruct class.
I took a look at the StructUtils plugin and the FInstancedStruct. I see that there is a SetInstancedStructValue and GetInstancedStructValue, which has a wildcard parameter and return value respectively. This is really close to what I am trying to achieve. Ultimately I am trying to create a function that takes a string and a struct type (or the struct itself) and attempts to initializes the struct with the string and then return the struct.