Event tick line tracing, displaying UI on hit, which solution is the most effective?

I’m talking in terms of processing power.

I have an UI widget displaying “Press [F] to use” whenever my trace generates a hit. My trace is set to activate on event tick.

I can either:

  1. Create the widget and add it to viewport every time a hit is generated (with the help of a bool variable to check if it is already up), and remove the return value from parent if no hits are being generated

  2. Create the widget and add it to the viewport once on event begin play, hidden by default, and use the IsVisible function to determine whether I should set it to visible.

The blueprints to better explain what I mean:

What is the more efficient solution? Or is there a better solution altogether? Thank you.

If you expect to use this Widget over the course of the entire game, i would create it once and determine if it needs to be shown or not and act accordingly.

Of note, SetVisibility on a Widget component has certain pitfalls depending on what it is. For example, making an ProgressBar invisible will render any Binds it has moot, they will not be executed unless the component is visible.

Also RemoveFromParent does not destroy the Widget, it simply unparents it, it still exists and can be added to the viewport again without the need to create it again if you Set it in a variable.