Access widget component through blueprint

Hello,

I have Blueprint Class which contains a Widget Blueprint (so I can spawn it into the world, like widket in 3D space), and that Widget Blueprint have some Text components, for example with name “Name”, how can I access that Text component Name through Blueprint Class?

Because I want to change text in Widget Blueprint through Blueprint Class.

1 Like

If you’re using the WidgetComponent you can get the widget and cast it to your WidgetBlueprint class then you can access whatever you want.

4 Likes

Yes Widget component which contains Text component.

Thank you for reply, but I have that Widget inside another Blueprint Class, and I want to change it from another Blueprint Class (that class has tag called “projector”).
Look:

I get into the Blueprint Class using tag, but then I don’t know how to get into that Widget inside that Blueprint Class.
I hope you understand me :slight_smile:

Widget Component can’t contain a Text Component, which is added in the menu you see in the image above. You must mean a Text Widget, right?

Have a look at SenToRious’ answer. That’s precisely how you access a normal widget embedded in a widget component.

To answer your question directly:

I get into the Blueprint Class using
tag, but then I don’t know how to get
into that Widget inside that Blueprint
Class. I hope you understand me :slight_smile:

When you create a widget inside the actor, create a reference by right clicking the Return Value pin and promoting it to a variable. This will allow you to access it later:

244340-untitled.png

Do this in your actor.

I see, drag from the Array Element and Cast to the Blueprint class that has the widget, and you should have access to that widget.

This is Blueprint Class which contains widget:

This is Event Graph of that Blueprint Class:

This is Widget Blueprint (I want to access text called Name and change it from another BP):

This is Blueprint Class from which I want to change text in Widget Blueprint:

As you can see I cast to Projector (Blueprint Class which contains Widget Blueprint) and then I access variable ProjectorWidget (I Promoted it to Variable as you said) and from that reference I cannot access any Text inside Widget Blueprint.

@SenToRious please check my comment answer to @Everynone because it is quite long.

Open the widget, select the text and tick isVariable in the upper right corner of its details panel. Some widgets are not exposed as default:

244382-untitled.png

1 Like

See my answer below.

If you combine my first answer with your reply on @Everynone answer, you’ll have your answer. Drag a pin from your ProjectorWidget (you got it from Cast to Projector) and call Get User Widget Object then cast the result to the widget inside of the ProjectorWidget (similar to my image) and now you should have the ability to use that widget class.

Thank you and this is my code now:

It should change text, but it doesn’t, there is still default text :confused: without changes.

Here’s the full thing:

@Everynone thank you, but I don’t have option for Cast To Embedded as you can see:

And Projector Widget ref is not compatible too:

This is my whole Projector Blueprint Class:

Embedded is just the name of my widget, your widget is called Projector Widget. Also, you cannot cast while dragging Execution wires (the white ones), use the data wires, they are context sensitive and will give you a sensible range of choices.

You’re trying to cast to a widget (ProjectorWidget), cast to a widget component instead (Projector).

Take a closer look at the image I posted, especially at the comments. It seems you’re not following it right. You’re trying to cast by dragging the white wire while you should be Getting User Widget Object first.

One note, this will not work in the Construction Script.

Thank you that Get User Widget Object works, but I still cannot cast to embedded widget, no option for it.

You should mark this as answered so others can find it easily.

@Everynone ah, it works now :slight_smile: Thank you very much !! Sorry but Im new and Im still learning :slight_smile: But I love it :slight_smile:

@Everynone Thank you very much, it works now :slight_smile: Sorry but Im quite new, and I am still learning how does blueprints work, but I love it! :slight_smile:

Again, as I said. Embedded widget is just the name I gave it. Use the name of your own widget:

Follow this, instead of Embedded, cast to Projector Widget instead.