Widget component in a different BP

I got a UIActor (BP Class) and in there is a Widget component. I want to resize the Draw Size but it should be called from an other Widget BP I tried the following but I was asked for a target in the call function which made my idea not working.

Left side is in the UIActor where the function is defined.
Right side is in the other BP Widget where I want to call the function. But the problem is I would need to assing a target wich should be the widget component from the UIActor but that is in a different BP. Is there a way to make it work?

Yes. Actor instances do not know about one another’s existence, though. It’s your job to find them and tell the editor where they are. Think about how, when, where those actors come into play. Also, comms are circumstantial; how to do it and which methods to choose depends on the given scenario.


Note this is one of the best documented topics:

1 Like

Just fixed it by adding a simple block called GetAllActorsOfClass.


If somebody wants do do the same

I’ve been tinkering with this for a while and I did manage to get it to work, but I’m still not convinced this is the best way of doing it. I asked AI to clarify it for me but I feel like I’m being lied too.

Let’s recap. You have an actor in your level which has a widget component that you wish to re-size using another widget, created say, on your player character?

Here my solution. Please, if someone knows a better way, let us know. I tried using Event Dispatchers but I will admit I do struggle to get them to work for me every time. :frowning:

Interface Blueprints.

  1. BPI_PassRefToSelf (with function “Set Reference” and input pin “Actor Reference” of type Actor)
  2. BPI_SetDrawSize (with function “New Draw Size” and input pin “New Size” of type Vector2D)


Widgets:

  1. WBP_WidgetToResize. This is the widget you will be re-sizing. I will live inside your BP_ActorWithWTR (Actor with Widget to Resize).
  2. WBP_ControlPanel. Widget we will create from your player character. I will have 3 buttons that we will use to change the size. You will also need a variable (Actor Passed Over From Character) of type Actor. In details for this variable check, Instance Editable and Exposed on Spawn. This could be an existing widget you already have in your game.

Actor with widget to resize (BP_ActorWithWTR). This is where you widget component lives. I called it Super Widget and in details I made sure I set it to WBP_WidgetToResize. I kept the default size of 500 by 500.

Still with me? :slight_smile:

Now, go to your player character. Click on Class Settings and under Implemented Interfaces add BPI_Pass Ref To Self interface.

In the same blueprint (character) - Implement this interface (it will be shown on the left side where you functions/macros/variables are). Double click on it and you should get a new node on the graph.
Promote what’s coming through that interface to a variable. I called it Actor Actor.

Still in the same blueprint, lets create our Control Widget and pass over our newly created Actor Actor.
Compile & Save.



Open BP_ActorWithWTR. Similar to character we need to implement our second interface called BPI_SetDrawSize. Follow the screenshot.
Compile & Save.

Finally, open WBP_ControlPanel and make it look something like this.

End Result should be something like this:

YouTube Video

I intentionally didn’t use Get all actors of class here. It might not be a big of an issue with just one of them in the level but it’s good practice to use interfaces. Please correct me if I’m wrong.
That’s the best I could do. Hope it helps.
Please, let me know if you need me to clarify something or if I missed something. I might edit this post if I spot any mistakes.

2 Likes

@DonBusso How about that? OP even flagged it as a solution - of the worst kind. :innocent:

1 Like

You are probably right, my thing might be an overkill. But I don’t want him to get into a habit of using get all actors of class for everything, since it’s not a good practice?

Edit: took me a while to type all this before I noticed it was solved. Apologies.

1 Like

On the contrary, you poured your heart & soul into a great answer :1st_place_medal: And worry not, OP will be back here if they ever add a 2nd actor and the GetAll node stops working…

1 Like

Thank you for taking so much time to explain it all. That was hard to follow though. Your way of fixing it is propably a better way then I did it but as long as my way keeps working I wont change that because it didnt work until I changed some value which I dont understand. But with you explanation I finaly understood how References even work! But I as far as I know using functions and the GetAllActorsOfClass and then selecting my UIActor works the same way. But it didnt work for another problem but luckily your way of doing it worked so we solved two problems at once. Thank you again for taking so much time for something that you propably dont even need in you project!

2 Likes

No worries. I like to give my absolute best. I have plenty of free time at the moment, hence I’m here, trying to help anyone and get some work of @Everynone shoulders. (I remember you from Answer Hub days buddy!)
You can always come back to it later when you get more comfy with Unreal.
Just don’t make a habit of using get all actors of class because it’s opening another can of warms. It’s okay for quick prototyping and testing but it can really hurt you in a decent size project.

1 Like

Thats why I changed to your way of doing it and it works fine thank you!

1 Like