Passing generic Structure Object to C++ Function

Hi,

I’m trying to implement a function in C++ to which I can pass an object of any structure as a parameter.

Unfortunately this fails because of the type of the passing parameter.

Here is an example of what I would like to accomplish with an user defined structure:

271942-poststructure.png

It seems like the type needs to be FStructOnScope, so, my function would need to look like

static FString DoSomethingWithStructInstance(const FStructOnScope* StructData);

But FStructOnScope isn’t supported, is that the wrong type or is there a way to accomplish what I want?

Thank you in advance

1 Like

Would be interesting to know how to do this. I have tried to figure this out but never did. The best advice I got was looking into the “wildcard” slots for things like the “For Each Loop” macros and other nodes that take in wildcard data and see how UE4 source handles it.

Got it working with some variation of [Tutorial] How to accept wildcard structs in your UFUNCTIONs - Community Content, Tools and Tutorials - Unreal Engine Forums

It’s not nice, but atleast it works.

Found a forum post with an explanation, thanks to the wildcard keyword.

I hoped for a cleaner solution, but it seems solid to me.

https://forums.unrealengine.com/community/community-content-tools-and-tutorials/27351-tutorial-how-to-accept-wildcard-structs-in-your-ufunctions?56537-Tutorial-How-to-accept-wildcard-structs-in-your-UFUNCTIONs=

Haha, glad I could point you in the right direction :slight_smile:

Doesn’t work for UE 5 :frowning:
Any new solutions?