Get the color of a widget element by line trace (Change widget interaction line color)

Hi all,

I have a widget and a widget interaction with a debug line. Now I want that the widget interaction adapts to that color, it is pointing on.

For instance if I point to a red button, the widget interaction should become red. Or if I point to a blue text, the widget interaction should become blue, etc.

Are there any suggestions for this?

o/
How do You set colors?
You can easily make variable on that widget and set color to it, then retrieve it while line tracing, by casting to that widget component or actor holding it (I’m assuming it is WidgetComponent) and setting the color on a button with the one from widget.



To split OutHit results use right click on it with:
image
or node: Break

Okey, but my widget component consists of different elements with different colors: buttons are blue, background is white, etc.

When I point with the widget interaction on a button, the widget interaction should appear blue. When I point on the background, the widget interaction should appear white, etc.

You could try to make it the following way:

  1. Wrap your widget tree in the retainer box and translate the widget to material.

  1. Use DrawMaterialToRenderTarget to write the widget to the TextureRenderTarget2D.

  1. Calculate the pixel address with Linetrace result and ReadRenderTargetPixel with it.

  2. Apply the resulting color

My Products

2 Likes

and translate the widget to material.

What do you mean with this?

Sorry. There is a more straightforward way:

You need to calculate the pixel address only.

3 Likes

Thanks for your help!
Do you have a hint on how to calculate the pixel address?

Try this:

But I’m not sure if this works with the widget component. I can’t check it now.

Thank you very much!
Unfortunately I’m not able to get “LineTraceByChannel” working. It works with any objects except my widget component :confused:

Try this:

image

Thanks, this helped. Now I’ve put everything together, but I don’t get the pixel address. I calculate it in that way you suggested:

But the PrintString only displays X=0, Y=0…

Yes, I’ve already set this to true…

And it didn’t help?

Nope, sadly not.

It works for me: