
Gaze(凝視) 是 HoloLens 互動輸入的第一種形式,告訴你 使用者 在世界上的位置,并讓你确定他們的意圖。
1.Gaze的用途
作為一個 Mixed Reality 開發者,Gaze 可以做很多事情:
- 你的應用程式可以将視線與場景中的全息圖相交,以确定使用者的注意力在哪裡。
- 你的應用程式可以讓使用者在真實世界的表面上放置全息圖,通過将視線與空間映射網格相交。
- 你的應用程式可以知道使用者什麼時候不看一個重要的對象的方向,這可以引導你的應用程式提供視覺和音頻線索轉向那個對象。
2.下載下傳Unity資源
資源下載下傳位址:https://github.com/Microsoft/HolographicAcademy/archive/v1.5.6-101.zip
這裡包含微軟官方教程中的資源檔案,為學習HoloLens提供很多友善。
3.Gaze
使用Gaze實作可視化的鎖定目标
- 建立一個Unity項目
- 按照第二章講到的方式,在 Hierarchy 中添加 HoloLensCamera 元件
- 在 Assets 中添加檔案夾 微軟提供的資源拖入,Origami\Assets\Holograms 目錄下 Cursor.prefab & Cursor.prefab.meta ,Origami\Assets\Holograms\Support\Cursor 整個目錄
-
Microsoft HoloLens 開發(3): 全息圖互動方式 - Gaze - 将 Assets 中的 Cursor 拖入 Hierarchy 中
- 在 Hierarchy 中輕按兩下這個 Cursor 對象 , 可以仔細觀察這個對象
-
Microsoft HoloLens 開發(3): 全息圖互動方式 - Gaze - 在 Hierarchy 面闆選中 Cursor 後,右鍵出現 Inspector 面闆
- 在 Inspector 面闆設定 Scale 的 (X : 12,Y : 6,Z : 12)
- 在 Inspector 面闆選擇 Add Component 後,出現下拉菜單選擇 New Script
- 輸入腳本名稱 WorldCursor 回車
-
Microsoft HoloLens 開發(3): 全息圖互動方式 - Gaze - 腳本會被建立到 Project 面闆的 Assets 目錄下
- 輕按兩下 WorldCursor 腳本會使用 Visual Studio 自動打開,替換下面代碼
-
Microsoft HoloLens 開發(3): 全息圖互動方式 - Gaze Microsoft HoloLens 開發(3): 全息圖互動方式 - Gaze
WorldCursor1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 public class WorldCursor : MonoBehaviour { 6 7 // Use this for initialization 8 void Start () { 9 10 } 11 12 // Update is called once per frame 13 void Update () { 14 15 } 16 }
- 在 Hierarchy 面闆随意添加一個 3D Object ,例如:Cylinder
- 在 Inspector 設定 Position (X : 0,Y : 1,Z : 3)
- 最後進行 build
- 效果如下
-
Microsoft HoloLens 開發(3): 全息圖互動方式 - Gaze