I swear I had this working last night then I opened it this morning and get this… What do I do to fix it?
It’s a little hard to say from just this snippet. Usually this error occurs because someone has created polymorphic structures (one USTRUCT derived from another) which UE4 allows but doesn’t support particularly well. So from the error I would have to assume that the type of ClothingContent array and ClothingPiece pin are not the same and that from the way you’re using it the ClothingContent type derives from ClothingPiece type.
If that’s the case, the only real solutions are to either make that type derive from UObject (which will allow you to pass them around as a polymorphic type) or create alternate “Create … Widget” functions that take the other structure types.
I’m not sure what the problem was but I ended up fixing it by just deleting the For Each Loop and Create Widget nodes and then re-adding them and hooking everything back up in the same place.
Or perhaps it was only a temporary fix… my solution feels like I just slapped a bandaid over a gunshot wound. This blueprint breaks the exact same way every time I re-open the project.
Oh man, that’s going to tough. There’s definitely something weird going on if you’re able to connect them up initially but then the types are wrong on a reload.
What happens if you just create one for the first element instead of all of them? So wire up a ‘Get’ node to the ‘Create Widget’. Not as a final solution, but just as a test. 'Cause if that works (and the connection is maintained after closing and re-opening the project) you might be able to do a hand made loop using ‘Get’ instead of the ‘ForEach’ macro.
I super appreciate the help! I’m just fumbling through all this Blueprint stuff since I’m more about creating the visuals of a game.
Here is what I came up with, replacing the For Each Loop with a Get node. When I compiled and tried it out everything seemed to work fine. Then I reloaded the project and while it doesn’t say there’s anything wrong with the script, it doesn’t work properly. It seems to understand that there is a piece of clothing there as the button shows up but the name of the item doesn’t appear in that button and clicking it does nothing.
There were a lot of different kinds of Get nodes, maybe I am using the wrong one? I pulled off of “Target Clothing Content” and chose “Get (a ref)”.
That one should be fine: You don’t have your ‘Get’ node output pin connected to the ClothingPiece pin of ‘CreateWidget’.
I see, this seems to be the last bit that keeps causing issues. I have to recreate the Create Widget node to be able to hook the Get node into it. Works fine. Reload the project then it’s not connected anymore and also won’t let me connect until I remake the widget node etc etc
One thing I’ve thought of trying is remaking the Clothing Content variable. I open up the Inventory Component, delete the variable, then make a new one (which is a Structure), but every time I hit compile the engine crashes.
Maybe this is no longer an issue… But a lot of people encounter issues when they use struct arrays. The majority of responses are to not use struct arrays, even though the engine lets you.
Sorry, I think I’m at about the limit of the help that I can give remotely. It doesn’t seem like you’re doing anything obviously wrong, but without my hands on it… well… really sorry.
The only other option I can think of would be to move some parts into C++, but that may not be an option for you.
That’s a great link ConradG. I knew blueprint support for structures had some issues, but didn’t realize it was so bad. I tend to do more with C++ than blueprint.