I am setting a text variable that is linked to a text block. I am setting the text variable from a separate widget that is resized from a component blueprint. But every time I set the text variable, the text block doesn’t update. I’m printing the variable name using print string. The string is printing the correct text, but the text block isn’t doing anything. The code is from Unreal University’s video on an inventory system, but I want it so that whenever I hover over one the slots, it prints the item name to the text block. PLZ help! Thanks!
Please post script.
I am setting a text variable that is linked to a text block.
This is already ambiguous, for example. Linked how?
If you need a more detailed view of the code, here is the tutorial I followed: https://www.youtube.com/watch?v=b2atcZWYi3E&pp=ygUbVW5yZWFsIHVuaXZlcnNpdHkgaW52ZW50cm95
You create a widget and update it here. But you never Add the widget to the Viewport. At least not here. How do you add it?
I added the widget to the viewport in the inventory component.
Nonsense. I could see the script.
The widget I’m adding to the viewport in the item blueprint, is for an interact prompt.
This code is in the inventory component
As for the widget you were asking about, that code sample only makes the widget a variable.
OK, thanks for sticking with me.
The widget polls this variable every frame:
Where is the part of the script that updates Object
text variable?
So, this is inside the inventory widget:
Some sort of slot widget is supposed to update it:
How does this slot get access to the inventory - the reference we see above?
I am confused a bit. Does it mean that every slot creates an inventory?
Yes. Every slot is added to the inventory in the inventory blueprint component.
Yes. Every slot is added to the inventory in the inventory blueprint component.
You say this but then we have this:
Which apparently is some kind of slot - and this slot (are there many?) very clearly creates an inventory widget. There are too many moving pieces here to make sense out of it. Again, this might be a me issue.
Perhaps you could produce some overarching architecture of what we’re dealing with:
- there is an actor component owned by the player
- the component creates an inventory widget
- the inventory widget hosts slots with buttons
- pressing a button does not update a text field in the inventory widget in the 2nd bullet point
Something that makes sense for your project, ofc.
So overall, there are 10 slots. This code is in the inventory component.
Super super sorry. I forgot to tell you this. But this function is loads the slots along with the resize node.
I don’t fully understand what you mean by overarching architecture tho.
Would you mind elaborating on that a little bit more please?
I think I found a work around for this problem.
I made this separate widget with a te4xt block which I bound to a variable called object name. And whenever I hover over the slot button, I add this widget to the screen, and I set the object name variable to the name of the item from the struct script. I don’t know if this will cause more problems further down the road, but I think it works for now.
Thanks for all the help! I really appreciate it!