- Home /
U3DXT basic Dialog box Question
I just bought the u3dxt plugin and want to display a simple dialog box with a "OK" and "Cancel" buttons. this makes that happenGUIXT.ShowAlert ("Title", "Body", "OK", new string[] { "Cancel" });
but how to do i know what button was pressed?
Answer by u3dxt · Mar 11, 2014 at 05:51 PM
Hi, you can subscribe to GUIXT.AlertDismissed event (http://u3dxt.com/api/?topic=html/E_U3DXT_iOS_GUI_GUIXT_AlertDismissed.htm). The example in Assets/U3DXT/Examples/core/GUIBasics has code on how to use it.
Answer by m123al · Mar 12, 2014 at 01:40 AM
i have another question about AlertDissmised. If i have two dialog boxes and a ok button for both how would i check which "OK" was clicked?
In iOS, it only displays one alert at a time. Although you can call it a second time before the first one is dismissed, but you should design your app to avoid this.
right but i meant, say if i have an if statement where it says
if (e.selectedButtonTitle == "Ok") { DoSomething(); }
how would i know which popup the "Ok" it came from
Got your question.
You can do it like this:
void Alert1() {
GUIXT.AlertDismissed += Callback1; // subscribe it
GUIXT.ShowAlert("alert1", ...);
}
void Callback1(object sender, AlertViewDismissedEventArgs e) {
GUIXT.AlertDismissed -= Callback1; // unsubscribe it
if (e.selectedButtonTitle == "O$$anonymous$$")
...
}
void Alert2() {
GUIXT.AlertDismissed += Callback2; // subscribe it
GUIXT.ShowAlert("alert2", ...);
}
void Callback2(object sender, AlertViewDismissedEventArgs e) {
GUIXT.AlertDismissed -= Callback2; //unsubscribe it
if (e.selectedButtonTitle == "O$$anonymous$$")
...
}
You can make it more compact but this shows the concept. Hope this helps.
Your answer
Follow this Question
Related Questions
How to get local currency u3dxt 1 Answer
Native GUI-Style on IOS 2 Answers
Store/Stack Items 0 Answers
UnitySendMessage does and doesn't recognize receiver in 2 similar instances 0 Answers
Access Native Video files from Unity on Android / iOS 0 Answers