MRが楽しい

MRやVRについて学習したことを書き残す

公式チュートリアル「MR and Azure 301 2~4章」を試してみる

本日はチュートリアルの実施枠です。
Academyの「MR and Azure 301: Language translation」の実施内容をまとめます。
docs.microsoft.com
前回記事の続きです。
bluebirdofoz.hatenablog.com
今回は「Chapter 2 ~ Chapter 4」です。

Chapter 2:Set up the Unity project

Chapter 3:Main Camera setup

チュートリアルページではプロジェクトの基本的な設定項目について全て手動で行っています。
これらの設定項目は MRTK を利用すれば自動で設定可能です。本記事では MRTK を利用します。

以下の手順ページの「HoloLens(WindowsMR) プロジェクトの基本設定」までを実施したプロジェクトを作成します。
bluebirdofoz.hatenablog.com
f:id:bluebirdofoz:20180807023046j:plain

InternetClient と Microphone の利用が必要なため、capabilites の設定を行います。
メニューから Mixed Reality Toolkit -> Configure -> Apply UWP Capability Settings を開きます。
f:id:bluebirdofoz:20180807023059j:plain

「Apply UWP Capability Settings」ダイアログが開くので、「InternetClient」と「Microphone」にチェックを入れて「Apply」を実行します。
f:id:bluebirdofoz:20180807023420j:plain

Chapter 4:Setup Debug Canvas

翻訳の入力と出力を表示するには、基本的なUIを作成する必要があります。
データを表示するためのいくつかの Text オブジェクトを持つCanvas UIオブジェクトを作成します。

1.hierarchy パネルの空の領域を右クリックして、UI -> Canvas でキャンバスを追加します。
2.キャンバスオブジェクトを選択した状態で、Inspector パネルを開き、「RenderMode」を「WorldSpace」に変更します。
3.次に、Inspector パネルの Rect Transform で次のパラメータを変更します。
Pos-X:0,Y:0,Z:40
Width:500
Height:300
Scale-X:0.13,Y:0.13,Z:0.13
f:id:bluebirdofoz:20180807023120j:plain

4.作成したキャンバスを右クリックして、UI -> Panel でパネルオブジェクトを追加します。
このパネルは、シーンに表示されるテキストの背景を提供します。
5.更に、作成したパネルを右クリックして、UI -> Text でテキストオブジェクトを追加します。
これを繰り返し、4つのテキストオブジェクトを作成します。
f:id:bluebirdofoz:20180807023129j:plain

6.各テキストオブジェクトの Inspector パネルを開き、それぞれ以下の通り設定します。
・RefTransformコンポーネント

NameTransform-PositionWidthHeight
MicrophoneStatusLabelX:-80,Y:90,Z:030030
AzureResponseLabelX:-80,Y:30,Z:030030
DictationLabelX:-80,Y:-30,Z:030030
TranslationResultLabelX:-80,Y:-90,Z:030030
・Text(Script)コンポーネント
NameTextFontSizeFontStyle
MicrophoneStatusLabelMicrophone Status:20Bold
AzureResponseLabelAzure Web Response:20Bold
DictationLabelYou just said:20Bold
TranslationResultLabelTranslation:20Bold
f:id:bluebirdofoz:20180807023139j:plain

7.更にこれらの各テキストオブジェクトに対して、子オブジェクトのテキストオブジェクトを作成します。
これらはアプリケーションの出力を表示します。
8.各テキストオブジェクトの Inspector パネルを開き、それぞれ以下の通り設定します。
・RefTransformコンポーネント

NameTransform-PositionWidthHeight
MicrophoneStatusTextX:0,Y:-30,Z:030030
AzureResponseTextX:0,Y:-30,Z:030030
DictationTextX:0,Y:-30,Z:030030
TranslationResultTextX:0,Y:-30,Z:030030
・Text(Script)コンポーネント
NameTextFontSizeAlignmentColor
MicrophoneStatusText??20Center0032EAFF
AzureResponseText??20Center0032EAFF
DictationText??20Center0032EAFF
TranslationResultText??20Center0032EAFF
f:id:bluebirdofoz:20180807023157j:plain

Chapter 4 はここまでです。
次回は Chapter 5 を実施します。
bluebirdofoz.hatenablog.com