If I were doing this I wouldn’t attempt to set the default value at all.
Instead I would use the K2Node_MakeStruct to actually construct an instance and connect that to the input pin.
Or failing that for some reason (MakeStruct might not be easily usable from another module’s code), using a CallFunction node that returns an instance of the struct. Basically doing an end-run around MakeStruct to call the NativeMake function directly.
i thought about that but at some point i still have to set the defaults on the pin from an FString. i thought there might be a better way like copying memory directly
it seems thats just how defaults are set and serialized
but to be clear im trying to copy a property from the k2node itself as a function param on the call function node. Since the k2node doesnt exist at runtime on expand node i copy it to the default value of the input pin
If you want to use the inline defaults, but sometimes (like this case) that’s more difficult than is worth it.
Ah, yeah that’s tricky. I’ve done that with engine structures that have their own ToString functions. Doing the export text call seems like the most generic approach. You’re worried about maps or structs in the FMyStruct? or something else? One way to check would be see what happens if you add an FMyStruct to a DevSettings or UserSettings so that it’s written to an ini. I know maps/structs worth there just fine. There are various things that won’t work very well exported to text.
Also, SetPinAutogeneratedDefaultValue is more for the blueprint UX. You can just set Pin->DefaultValue to what you get back from ExportText (or directly pass it in for the function’s out parameter). Or are you actually trying to do this during AllocateDefaultPins? Are you trying to default the structure pins to something different than the default values of the structure normally?
Maybe it’s worth not having the structure pin at all, and using reflection to make actual pins for each of the properties instead. Sort of like the ExposeOnSpawn pins when creating a UObject.
Well, not all. That’s why DefaultTextValue and DefaultObject are also available. But yeah, anything not those generally supports a conversion to string in one way or another.