AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
DialogButton.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
5 using HoloToolkit.UX.Dialog;
6 using UnityEngine;
7 
8 namespace HoloToolkit.UX.Buttons
9 {
13  public class DialogButton : MonoBehaviour
14  {
15  private Button buttonComponent;
16 
17  private DialogShell parentDialog;
18 
22  public DialogShell ParentDialog
23  {
24  get
25  {
26  return parentDialog;
27  }
28  set
29  {
30  parentDialog = value;
31  }
32  }
33 
37  public Dialog.DialogButtonType ButtonTypeEnum;
38 
39  private void OnEnable()
40  {
41  buttonComponent = GetComponent<Button>();
42  buttonComponent.OnButtonClicked += OnButtonClicked;
43  }
44 
45  private void OnDisable()
46  {
47  if (buttonComponent != null)
48  {
49  buttonComponent.OnButtonClicked -= OnButtonClicked;
50  }
51  }
52 
58  public void OnButtonClicked(GameObject obj)
59  {
60  if (parentDialog != null)
61  {
62  parentDialog.Result.Result = ButtonTypeEnum;
63  parentDialog.DismissDialog();
64  }
65  }
66 
71  public void SetTitle(string title)
72  {
73  CompoundButtonText compoundButtonText = GetComponent<CompoundButtonText>();
74  if (compoundButtonText)
75  {
76  compoundButtonText.Text = title;
77  }
78  }
79  }
80 }
DialogButtonType Result
Property reporting the Result of the Dialog: Which button was clicked to dismiss it.
Definition: DialogResult.cs:88
Dialog that approximates the look of a HoloLens shell dialog
Definition: DialogShell.cs:20
DialogResult Result
Can be used to monitor result instead of events
Definition: Dialog.cs:49
Handling click event and dismiss dialog
Definition: DialogButton.cs:13
void OnButtonClicked(GameObject obj)
event handler that runs when button is clicked. Dismisses the parent dialog.
Definition: DialogButton.cs:58
void SetTitle(string title)
Setter Method to set the Text at the top of the Dialog.
Definition: DialogButton.cs:71
Used to tell simple dialogs which buttons to create And to tell whatever launched the dialog which bu...
Definition: Dialog.cs:17
Action< GameObject > OnButtonClicked
Event fired when click interaction received.
Definition: Button.cs:76
void DismissDialog()
Function to destroy the Dialog.
Definition: DialogShell.cs:282
Dialog.DialogButtonType ButtonTypeEnum
The type description of the button
Definition: DialogButton.cs:37