Hey,
I want to script a pop up message class and be able to call it whenever I want (something like Windows form message just with Unity UI).
There are some issues I am not sure how to solve:
First, I want to disable all UI controls while the pop up is showing
Second, I want it to stand out, so I thought about making the entire screen a little darker beside the pop up message itself.
Create your gui. Add a full screen image with raycast enabled behind it to block clicks. Gui should look like whatever you want it to be. When you want to trigger it, turn it on by setting the gameobject active. If you need to pass it values, set up a script that has a method that takes values and then turns the gameobject on.
Okay, i never used the GUI system before, I always thought the GUI is an older outdated version of the UI system.
When should I use GUI and when should I use the UI?
Brathnann probably meant the new system! Both are GUI systems, after all!
So the idea is to always have the popup around, but deactivated. When you need the popup, you call a method that sets it active and sets the text to the correct value.
That implies that your popup box is a singleton! That’s probably okay.
Create a Panel (darker as you want) that take the entire screen, and whatever you want to popup as child of the panel.
Desactivate the panel on the inspector.
The panel prevent the mouse action on every objects that are under it
E.G.:
There’s a panel over the whole screen. My menu on the left can’t be interactable (the panel is over). But I can interact with the inputfiel (it’s a child of the panel).
Yep, that is what I meant.
It could be a singleton with a dontdestroyonload, or it could just exist in each scene on it’s own. It would just depend on need.
For OP, @renaiku gives a good example of how it basically works. A full size UI object with blocks raycast is there to keep from clicking through and serves as a fade background while the other stuff is on top of it so it can be interacted with if you want (or just visible for a bit on a timer).
There are two ways. One is to use multiple canvases and use the sort order on the canvases.
The other way is that UI elements are rendered in the order they are setup
canvas
-ui1
-ui2
-ui3
Ui3 is drawn last, which means it’s on top. If ui 3 is the blocking panel/image, then it will block ui1 and ui2 from being clicked on.
Thank you guys, I manage to do that and it works perfectly!
I have one more issue which is unrelated to the topic but it is related to the UI.
It seems like my UI objects raycasts overlaps or really out of place because sometimes when I hover a UI object it highlight the wrong UI object.