Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
20170801 Holo MRDesignLab Buttons DialogAndMenuExample.cs
protected override void OnTapped(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
{
base.OnTapped(obj, eventArgs);
if (launchedDialog)
return;
SimpleDialog.ButtonTypeEnum buttons = SimpleDialog.ButtonTypeEnum.Close;
string title = string.Empty;
string message = string.Empty;
switch (obj.name)
{
default:
title = Dialog1Title;
message = Dialog1Message;
buttons = Dialog1Button;
break;
case "SquareButtonDiag2":
title = Dialog2Title;
message = Dialog2Message;
buttons = Dialog2Button1 | Dialog2Button2;
break;
}
launchedDialog = true;
StartCoroutine(LaunchDialogOverTime(buttons, title, message));
}
protected IEnumerator LaunchDialogOverTime(SimpleDialog.ButtonTypeEnum buttons, string title, string message)
{
// Disable all our buttons
foreach (GameObject buttonGo in Interactibles)
{
buttonGo.SetActive(false);
}
Result.gameObject.SetActive(false);
SimpleDialog dialog = SimpleDialog.Open(DialogPrefab, buttons, title, message);
dialog.OnClosed += OnClosed;
// Wait for dialog to close
while (dialog.State != SimpleDialog.StateEnum.Closed)
{
yield return null;
}
// Enable all our buttons
foreach (GameObject buttonGo in Interactibles)
{
buttonGo.SetActive(true);
}
Result.gameObject.SetActive(true);
launchedDialog = false;
yield break;
}
protected void OnClosed(SimpleDialogResult result)
{
Result.text = "Dialog result: " + result.Result.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.