I was reading through the USTRUCT documentation here: Structs, USTRUCTS(), They're Awesome - UE4: Guidebook, and in the example it shows that USTRUCTs can have member functions or methods. But how can those be called in Blueprint?
USTRUCT(BlueprintType) exposes the USTRUCT to Blueprint and setting UPROPERTY macros on the variables can make those Blueprint accessible, but using a UFUNCTION macro on the member functions is not allowed. At least, I’ve gotten errors whenever I’ve tried.
You can’t. The error message tells you exactly what the problem is, you can only have blueprint callable functions in classes and interfaces.
The solutions for this are 1) make your thing a UObject instead, 2) create a blueprint function library with the blueprint callable functions you want for your structure, 3) add static blueprint callable functions to some other UObject that you have that’s related to your structure.
If you didn’t say it, I was going to. I don’t know what’s worse, someone who answers but clearly didn’t read the OP or someone who responds with ChatGPT. Sometimes it’s accurate enough to work from, but I could have done that myself.
I appreciate the straight answer. Given the error, I was hoping there was another way – or maybe I had done something wrong.
Actually, I don’t even need it. When I saw that it was a possible option, I figured I’d try it. I was looking for a convenient way of setting Blueprint structs without having to split then drag 100 lines over and over whenever I want to set just one thing. Having a Set/Get method in the struct would have been a valuable time saver.
In the end, I’m just going to write a separate BlueprintCallable function in C++ that manages the struct data. It’s for a BP menu.
If that’s the case, you’ll want to use the built-in set member in structure method. That does exactly what you want- just enable any of the pins you want to change.
Set members in structure does it by reference, so any changes will be saved to the variable you input.