// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using TMPro; using UnityEngine; namespace Microsoft.MixedReality.Toolkit.UI { /// /// Handling click event and dismiss dialog /// public class DialogButton : MonoBehaviour { [SerializeField] private TextMeshPro buttonText; public TextMeshPro ButtonText { get => buttonText; set => buttonText = value; } /// /// A reference to the Dialog that this button is on. /// public Dialog ParentDialog { get; set; } /// /// The type description of the button /// public DialogButtonType ButtonTypeEnum; /// /// Event handler that runs when button is clicked. /// Dismisses the parent dialog. /// /// Caller GameObject public void OnButtonClicked(GameObject obj) { if (ParentDialog != null) { ParentDialog.Result.Result = ButtonTypeEnum; ParentDialog.DismissDialog(); } } /// /// Setter method to set the text at the top of the Dialog. /// /// Title of the button public void SetTitle(string title) { if (ButtonText) { ButtonText.text = title; } } } }