webviewstream/Assets/Scripts/DialogHandler.cs

31 lines
697 B
C#

using System;
using Microsoft.MixedReality.Toolkit.UI;
using UnityEngine;
public class DialogHandler : MonoBehaviour
{
[SerializeField]
private GameObject dialogPrefab;
public void OpenDialog(string title, string question, Action action)
{
Dialog dialog = Dialog.Open(
dialogPrefab,
DialogButtonType.Yes | DialogButtonType.No,
title,
question,
true
);
if (dialog != null)
{
dialog.OnClosed += (x) =>
{
if (x.Result == DialogButtonType.Yes)
{
action?.Invoke();
}
};
}
}
}