In the end, we did not get rid of the selection box when dragging and placing a new building as Nathan promised. Quite disappointed but I guess we can do it by exempt the UI layer out when doing ray cast hit to draw the selection box, so when we click on the buildings UI it would not draw it.
Anyone has any suggestion?
I believe what I did in the end was for the selection box, I got a hold of the building buttons.
Then I did a foreach over the building buttons.
For each button check if it’s currently building (I think we had a building boolean on those buttons already). If it’s building, then just return, and don’t do anything selection box wise.
Using UI layers sounds like a better idea to be honest.
Can you elaborate on how to use the UI layers to ignore clicks?
I’ve done a few experiments with IPointerDownHandler
checking against a “UI” layer containing the button, but the problem seems to be that the UnitSelectionHandler
is written to just query mouse coordinates directly, not their interaction with a Canvas, so no events are generated.
I’ve also tried a layer-constrained Physics.Raycast
but it can only detect a UI click if the UI objects have colliders on them, which doesn’t feel like the right solution.
I’ve also tried a GraphicsRaycaster
approach but that didn’t work either because it ends up hitting the entire BuildingDisplay
canvas which covers the entire screen.
Sorry piwakawaka, I just have an idea like that but never implement it yet now I know that there are heap of things that cannot be successfully implemented.
In the RPG course, there is a section about UI stopping mouse click interact with the map. I will look into it, surely there’s a way to apply it in here.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.