I’m clear on how I can make a panel with text and buttons to make a type of message box.
What I can’t figure out is how to to restrict input when this message box is visible. With a typical alert box all ui input is disabled except for input directed at the alert box.
Now if you put that on the top object it will also consider your alert items. I would probably create an array to get those and ignore them:
public Selectable [] ignoreList;
private Selectable[] obj;
void Start()
{
var o = GetComponentsInChildren<Selectable>();
List<Selectable> selectList = new List<Selectable>();
foreach(Selectable s in o)
{
if(ignoreList.IndexOf(s) < 0){
selectList.Add(s);
}
}
alertItems = selectList.ToArray();
}
void SwitchInteraction(bool value)
{
foreach(Selectable s in obj){
s.interactable = value;
}
}
So in ignoreList, you place all the selectable items from your alert box. Start will get all selectable from the canvas and that will include the alert box items. Then you iterate through that collections to see if some are in the ignoreList collection. IndexOf returns -1 if the item is not in so if you get a negative value, it means you selectable is not from the alert list you add it to the temporary list. At the end you turn the temp list to array.
The easiest way to do this is just put a panel behind the alert box that covers the whole screen, this blocking all other input. You can make it white with an intermediate alpha value for a fade type effect. Note this does cost in terms of draw calls.