x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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.

Product Version: UE 4.15
Tags:
more ▼

asked Jun 14 '18 at 07:47 PM in Blueprint Scripting

avatar image

t0msk
65 10 16 22

avatar image t0msk Jun 14 '18 at 09:49 PM

Yes Widget component which contains Text component.

avatar image Everynone Jun 14 '18 at 10:02 PM

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 :)

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:

alt text

Do this in your actor.

untitled.png (23.1 kB)
avatar image t0msk Jun 15 '18 at 10:52 AM

This is Blueprint Class which contains widget: BP Widget

This is Event Graph of that Blueprint Class: BP Event Graph

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

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

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.

avatar image Everynone Jun 15 '18 at 10:57 AM

See my answer below.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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:

alt text

untitled.png (10.9 kB)
more ▼

answered Jun 15 '18 at 10:55 AM

avatar image

Everynone
14.7k 76 25 61

avatar image t0msk Jun 15 '18 at 11:36 AM

Thank you and this is my code now: Blueprint

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

avatar image Everynone Jun 15 '18 at 11:38 AM

Here's the full thing:

alt text

capture.png (163.1 kB)
avatar image t0msk Jun 15 '18 at 04:48 PM

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

And Projector Widget ref is not compatible too: Projector Widget

This is my whole Projector Blueprint Class: Projector Class

avatar image Everynone Jun 15 '18 at 04:51 PM

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.

avatar image t0msk Jun 15 '18 at 04:54 PM

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

avatar image Everynone Jun 15 '18 at 05:00 PM

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

alt text

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

untitled.png (249.1 kB)
avatar image t0msk Jun 15 '18 at 05:00 PM

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

avatar image Everynone Jun 15 '18 at 05:01 PM

Haha, wicked! That thing is kind of complicated, it's a layer on top of another layer. :D

avatar image SenToRious Jun 15 '18 at 05:33 PM

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

avatar image t0msk Jun 15 '18 at 06:22 PM

@Everynone yea.. :D

@SenToRious It is marked :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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. alt text

widget.png (111.0 kB)
more ▼

answered Jun 14 '18 at 08:56 PM

avatar image

SenToRious
480 4 7 12

avatar image t0msk Jun 14 '18 at 09:55 PM

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: Access widget 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 :)

avatar image SenToRious Jun 14 '18 at 10:12 PM

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.

avatar image t0msk Jun 15 '18 at 10:53 AM

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

avatar image SenToRious Jun 15 '18 at 11:20 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question