I’m new to the engine, and I’m trying to create a Tower Defense game, when I click on the building spots it shows a Build UI, but I want to a way to hide it on any click on the ground (any unhandled click), I tried search in many places but didn’t found a right way to achieve that
depends how you currently handle clicks but
have a bool for instance say IsInBuildUI? if true close build menu if false open build menu.
have the widget consume input so it doesnt close the menu on selection
I don’t have a IsInBuildUI variable, but same something that works similar to it: a variable with the reference to the UI, if the variable has any value then it’s in Build UI.
This is the logic in the Level Blueprint:
My main problem is that I don’t know what to use to identify any click on the screen and how identify when this click was not handled by any other button.
For example, I could override the OnMouseButtonDown but this would be executed every time even the click was about the handled by another button
Also, this is the structure of my build UI
you could just create a left mouse button input on your player controller, and test there if last widget is valid.
id move that stuff from your level blueprint into your player controller too so its all in one place plus its more relevant and modular
Got it, tried adding the “Left Mouse Button” on a Player Controller and it only shows the text when I click outside of the UI which is exactly what I expect, so it solves the problem.
But now I just want to know one more thing for curiosity, if with the “Left Mouse Button” it doesn’t triggers when clicking on a UI widget, how do I identify that any left mouse button clicked happened on the screen regardeless of the click being consumed by the UI or not
there should be a setting in the widget somewhere saying ‘consume input’ but im going from memory right now
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.