Hide Active Widget if Left Mouse is Clicked

Hi everyone!

I’m trying to build an interactive Archviz interaction where the player can change multiple materials, so far so good but I ran into an issue and not matter how much I google it or read about it I can’t seem to find an answer, you’re my last resort so I really hope anyone out there can help me.

You can click on the object you want to change its material, let’s say the floor, the widget comes up and if you click agin ON THE FLOOR the widget hides. The problem is that if once that widget is open and you click on the walls, the change material widget for the walls comes up on top of the floor widget and I don’t want that, what I want is that once ONE widget is already displayed on the viewport, if any other interactible object is clicked, the previous widget dissapears and the right one shows up. Does anyone know how to do this? I’ve trying for 3 days different methods but nothing works, thank you very much!

Also, if you have any idea how to outline the mesh that the user is currently mouse hovering would be very thankful as I can’t find a proper tutorial on that matter either.

Floor blueprint widget interaction:

I’m really dissapointed with this community, no matter what my issue is no one is able to give me a hint, including specially the developers. I do know for a fact this doesn’t happen in Unity forums…

  • how is this widget created, as in - where, which blueprint?
  • is it safe to assume that every element in the scene is responsible for creating and adding its own widget to the viewport?
  • do you destroy (remove from parent) the widget after hiding it or does it exist forever?
  • are all widgets identical or the scene actors have different ones associated with them

There are many ways of doing what you’re after but I’d rather suggest something that fits right into your existing workflow hence all the questions.

Hi Everynone, thanks for replying. Answering your questions:

  • how is this widget created, as in - where, which blueprint?
    Not really sure what you mean here, but every interactive object (floor, sofa, tables…) have their own actor blueprint where they are located. For the widget it goes the same, I have a widget for the floor, another one for the sofa, another one for the table… which is basically a duplicate of the first one.

  • is it safe to assume that every element in the scene is responsible for creating and adding its own widget to the viewport?
    So after answering the first question, yes it is, each one has its own widget.

  • do you destroy (remove from parent) the widget after hiding it or does it exist forever?
    They exist forever because if I add a remove from parent node the widget doesn´t come up again unlesss you restart the game, that´s not I want. What I want is that if a widget is active and the user left clicks somewhere else the widget that is active dissapears not that if it clicks on another interactive object the widget of that object comes up, overlapping with the previous one.


Thats the event on each interactive object.

  • are all widgets identical or the scene actors have different ones associated with them

All are the same except the one for the table which replaces the static object instead of material. The problem I have with that one is that the first option appears ok and the others are completely black.

Hope that helps and you can tell me what I´m doing wrong which I cant figure out, also if you know a better way to replace objects inside the widget I would really appreciate it, thank you very very much!

You can freely destroy and recreate widgets during run-time. Rather than creating all the widgets at begin play (lots of memory needed to keep them all active at all times!); create them onClick - play the animation, click again, play the animation in reverse to hide it - when the animation finishes, remove from parent. This will solve your issue immediately, dramatically lower the memory footprint and simplify things overall.

If you really only have one widget active at a time, you can get all Widget of Class and remove the one that sits in the viewport, and only *then *create the one for the clicked object. Alternatively, a much better option is to to keep a singe reference to the most recently created widget, ideally in one of the framework classes - in the player controller perhaps. This allows you to access the existing widget and handle it accordingly before creating a new one.

Thanks for all the help but I´m not really good with blueprints, as you might have seen by the way I construct mine. And all the technical details you mention I´ve got no idea how to implement them and where. I did try to create the widget onClick as you mention but doesn´t work, if I replaced the BeginPlay with the onClick it just doesn´t show up at all. At the same time if I add a remove from parent node after the animation node the widget doens´t appear at all aswell. I appreciate the help but without an event graph example where I can see what you mean I just don´t understand it at all, although blueprint is visual scripting after more than two years playing with it I´m still struggling a lot to understand the way you need to construct nodes to make it work.

I have around 8/9 different interactive objects on the scene and I do not see any performance issues the way I´ve done it, I know if I had 100 objects you wouldn´t do it this way but I really need to finish this project before the end of the year and I´m really stuck to figure out something as simple as hiding a widget once the user clicks. As well as changing static meshes trough a widget, the meshes appear completely black on the screen even though they are set as movable. Anyway, I really appreciate your help as you have been the only one willing to tell me how it should be done and I don´t doubt at all that what you´re saying wouldn´t work as you seem to know exactly what you´re talking about, is just I don´t have any idea of how to implement or where to put all that you said that´s all.

Thanks very much for your time.

Hey Mac3D, this is exactly what I need to achieve. Can you please help me if you achieved what you wanted, or to refer me to any tutorial because I am struggling on this too.