Reputation: 1
So I have an Inventory scene, where I have my UI and some buttons. In my main scene, I have a CanvasLayer so that all the UI follows the camera properly. However, when I put my Inventory scene as a child of my CanvasLayer, the buttons just don't work... I tried putting a button directly inside the CanvasLayer and it was clickable, as well as putting my Inventory scene outside the CanvasLayer. I really don't know why and I would like to keep my scene inside a CanvasLayer or any node that does the same thing.
Here is my main scene's CanvasLayer:
Here is my Inventory scene:
And here is my inventory (doesn't show mouse due to the screenshot, but I am hovering the buttons right now):
Upvotes: 0
Views: 49
Reputation: 325
This is likely a "Controls overlapping" scenario: a Node doesn't receive events because another Node handled them. The cause should be either:
Inventory's and F to pickUp's Rects overlap but the latter receives mouse input events before its sibling, and consumes them (either explicitly or implicitly), thus stopping event propagation.
According to the second image, Inventory's Buttons are separate Scenes; they may have additional child Nodes, at least one of which consumes mouse events before its parent, preventing event propagation as well. The Godot documentation has a relevant suggestion:
Sets [sic] mouse_filter to MOUSE_FILTER_IGNORE to tell a Control node to ignore mouse or touch events. You'll need it if you place an icon on top of a button.
About your attempts:
I tried putting a button directly inside the canvas layer and it was clickable...
I assume it worked because it was the last CanvasLayer's child and/or it had no children on its own, therefore it received input events as expected.
...as well as putting my inventory scene outside the CanvasLayer.
Same as before, it was deep down the Scene Tree and no other Controls were conflicting with it anymore.
Upvotes: 0