對話方塊 — MRTK2

對話

對話方塊控制項是提供內容相關應用程式資訊的 UI 重迭。 而且它們通常會需要使用者執行某種動作。 使用對話方塊來通知使用者重要的資訊,或是在完成動作之前要求確認或其他資訊。

範例場景

您可以在 DialogExample 場景中找到範例: MRTK/Examples/Demo/UX/Dialog

如何使用對話方塊控制項

MRTK 提供三個對話方塊預製專案:

  • DialogSmall_192x96.prefab
  • DialogMedium_192x128.prefab
  • DialogLarge_192x192.prefab

使用 Dialog.Open () 開啟新的對話方塊。 指定對話方塊預製專案、按鈕數目、標題文字、郵件內文、放置距離 (近或遠) 、其他變數) 。 對話方塊提供 [確認 (單一按鈕) ] 和 [選擇 (雙按鈕) ] 對話方塊選項。

public static Dialog Open(GameObject dialogPrefab, DialogButtonType buttons, string title, string message, bool placeForNearInteraction, System.Object variable = null)

開啟具有單一 [確定] 按鈕的大型對話方塊範例,放在遠方互動範圍 (注視、手部光線、運動控制器)

Dialog.Open(DialogPrefabLarge, DialogButtonType.OK, "Confirmation Dialog, Large, Far", "This is an example of a large dialog with only one button, placed at far interaction range", false);

開啟包含使用者選擇訊息的小型對話方塊範例,放置於接近互動範圍 (直接手部互動)

Dialog.Open(DialogPrefabSmall, DialogButtonType.Yes | DialogButtonType.No, "Confirmation Dialog, Small, Near", "This is an example of a small dialog with a choice message, placed at near interaction range", true);

如需詳細資訊,請參閱 DialogExampleController.cs DialogExample.unity 場景。