https://gfycat.com/ConventionalDirtyKiskadee
Dialog prefab is located under HoloToolkit/UX/Prefabs folder and dynamically instantiated with Unity's Instantiate() function. This prefab contains DialogShell script and Solver scripts.
You can find the code example in LaunchDialogScript.cs under SceneContent > SquareButton. It demonstrates the instantiation and response to a Dialog using the function Launch Dialog. The Dialog can be specified to have a single button, useful for communicating information to the user. The Dialog can also be configured to display two buttons, allowing the user to make a choice. The name of the selected button is returned to the script that opens the Dialog.
An instance of the Dialog is created using:
//fill dialogPrefab in the inspector:
[Serialize]
private Dialog dialogPrefab;
//then call:
Dialog dialog = Dialog.Open(dialogPrefab.gameObject, buttons, title, message);
The second argument to the Open function defines the caption or captions that the button(s) will have. They are identified by defining an enumerated value using Dialog.ButtonTypeEnum. To define two buttons, simply bitwise OR two enumerations:
Dialog.ButtonTypeEnum.Yes | Dialog.ButtonTypeEnum.No
The calling script can "listen" for the Dialog being closed by attaching an event Handler to the OnClosed Event of the Dialog.
In summary, the steps to create and launch a Dialog are: In a LaunchFunction() called by a Coroutine:
- Load Dialog Prefab into memory using Resources.Load("Dialog").
- Create an instance of the Dialog Prefab using Dialog.Open(...). This also Opens and displays the Dialog.
- Attach OnClosed handler to the dialog.OnClosed event.
The Dialog will stay in the user's field of view while the user can use gaze or controller targeting to make a button selection. Tag-along and billboarding interaction is achieved by using Solver scripts. When you select Dialog.prefab, you will be able to find Solver scripts for the size and distance control. In SolverConstantViewSize, you can adjust Target View Percent V value to modify the size of the Dialog window.
You can find more detailed information about the Solver System on this README page.