Skip to content

Instantly share code, notes, and snippets.

@elbruno
Created August 2, 2017 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/60963a1decd40147757c1cde8172879e to your computer and use it in GitHub Desktop.
Save elbruno/60963a1decd40147757c1cde8172879e to your computer and use it in GitHub Desktop.
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