I’m trying to create a modal-like UI. When the player clicks on the button, it opens a modal with a close button (similar to Bootstrap modals in web development).
However, when the modal is open, I can still select items covered by it. I want to prevent selecting items when the modal is open. I know I can achieve this by using variables, but I’m wondering if there’s a better solution, like an extension or something I might have missed?
To my understanding this is like menu
Put each menu layer on well different layer
Now to your click events you add layer is visible
Or while checking if others are not visible
You could check if object exist
You could flip some variables if something is pressed
Kinda few ways to pull it off
Yet one with layers make more sense
IF you do not want to hide layer that is below and only put something on top of what is there already
Then you would need to kinda create events for checking if layers are visible in cascade style
FOR EXAMPLE
Only layers that would be hidden are the ones that are not yet open
So lets say you have pause menu layer
On top of that would be audio settings layer
And on top of that you open game settings layer
So in this order
You would check for menu layer to work (which is most bottom layer)
Menu layer is visible
Audio layer is not visible
Setting layer is not visible
For audio layer
Audio layer is visible
Settings layer is not visible
For settings layer
Settings layer is visible
If you would want to open menu layers in not such cascade order
Then i would suggest going with variables
Yes, thanks. I have already created it using variables, but I think if we could lock objects or an entire layer, it would be easier to handle. I’ve seen this ‘Lock layer’ toggle in the Layers panel, but I couldn’t find it in actions or events.
If GDevelop has this option, we could easily create complex user interfaces. If there is no built-in method or extension for this, I think it could be added as a feature request. It might help in the future.
Lock layer or object in editor is only meant for editor itself
So you can’t move these objects
For example you would lock your background grass tiled sprite
So you can place and move your rocks flowers and house objects around without constantly moving grass by accident
For events it is totally different story
You could set opacity of all objects to 254 in editor
For object you want to be inactive
And simply check if their opacity is 255 or 254
Where when you enable some menu in game you would set its objects to 255
While set other menus to 254
There is condition to check if objects are on specific layer
So you have all tools you need to manage it
BTW you could use some variable
But i find it stupid to create vars for many things
I use stuff that already exist
So opacity is something we have already
And you can’t notice difference between 255 and 254 opacity
And if you insist you do you can go to 254.9 instead of 254
And use decimals like 254.8 254.7 and so go on
Even 254.991 and so go on
And you won’t need to have new variable for each object
So now only thing to do is setup your logic