littlewing

人間とコンピューターとメディアの接点をデザインするために考えたこと

MRDesignLabsメモ(1)

MRDesignLabs_Unityを触りながら、だらだらとメモ。

アイコンが表示されない時

HoloSymMDL2フォントのライセンス

  • 簡単に言うとMicrosoftのPlatform上で動作するものにしか使ってはいけない。(逆に言えばその範囲であれば、開発製品に組み込んでもok)
  • MRDesignLabライセンスがMIT Licenseなので、一緒にダウンロードできないように分けたのかな。
  • フォント同梱の「Hololens_EULA.txt」の内容は以下の通り(2017/6/26時点)

You may use the HoloLens MDL2 fonts or glyphs included in this file (“Software”) to design, develop and test your programs that run on a Microsoft Platform, a Microsoft Platform includes but is not limited to any hardware or software product or service branded by trademark, trade dress, copyright or some other recognized means, as a product or service of Microsoft. You are only permitted to distribute the Software in programs you develop that run on a Microsoft Platform. You may not distribute portions or individual elements of the Software, separate from the Software or in programs you develop for products or platforms that are not Microsoft Platforms. You may not transfer or sublicense these rights, including allowing others to redistribute the Software or individual elements of the Software. By using the Software you agree to these terms, if you do not agree to these terms, do not use the Software.

  • Windows Phoneなど用の、Segoe UI Symbolsとの関係性はどうなんだろ。また調べてみたい。

  • Excelで以下の操作で一覧表示できた。※やり方はここが参考になった

  • HoloLens MLD2 Symbols Font f:id:pigshape:20170626202025p:plain

  • HoloLens MDL2 Assets Font f:id:pigshape:20170626201825p:plain

  • UnityEditor内のCompoundButtonIcon.csからも一覧表示と選択できた。 f:id:pigshape:20170628083442p:plain

BoundingBoxTarget.csを設定したのにAppBar(メニュー)が表示されない

 gameobjectにcoliderが必要

BoundingBoxTargetを動的に設定すると例外が大量に発生する。

AppBarにメニューボタンを追加する

  • HoloLensオブジェクトにぶら下がっている、ManipulationManagerのAppBar Prefabの中で設定する。
  • AppBarのInspectorにある、Custom Buttonsにメニューボタンを追加できる。ボタン押下のレシーバーもここで設定可能。
  • イベントの受信は他にもいろいろな方法があるっぽい。

オリジナルのボタンでもDoneアイコンを使いたい

  • AppBar.csのAppBarStateEnumに新しい状態を追加する
        public enum AppBarStateEnum
        {
            Default,
            Manipulation,
            Hidden,
            ShowDone//オリジナルのstateを追加
        }
  • OnTappedにも状態に合わせたコードを書く。
protected override void OnTapped(GameObject obj, InteractionManager.InteractionEventArgs eventArgs) {

(省略)

                case "Pen"://ボタン名が"Pen"の場合
                    Debug.Log("PenTouch");
                    State = AppBarStateEnum.ShowDone;
                    break


(省略)
}
  • AppBarButton.csのupdate内にもクリック時のアイコン状態を追加設定する
                case AppBar.AppBarStateEnum.ShowDone://追加
                case AppBar.AppBarStateEnum.Manipulation:
                    // Show done / remove buttons
                    // The rest are hidden
                    targetPosition = manipulationOffset;
                    switch (template.Type)
                    {
                        case AppBar.ButtonTypeEnum.Done:
                        case AppBar.ButtonTypeEnum.Remove:
                            Show();
                            break;

                        default:
                            Hide();
                            break;
                    }
                    break;

開発時にキーボードで操作しずらい。動きが早すぎる

  • UnityEditor上のPlayモードで WASD QE でカメラの移動ができるが動きが早すぎる。
  • HoloLensオブジェクトにぶら下がっている、InputMappingのスクリプトInputDev.csのInputScaleパラメーターを調整することで、変更可能。
  • 好みによりますが、現時点では、
    • Virtual Cam Translateはx,yともに、0.3
    • Virtual Cam Vert and Rollはx,yともに、0.2 がちょうどよいかなと思っています

f:id:pigshape:20170626124522p:plain

ToolBarのボタンにアクションを設定する。

各ボタンごとに以下のスクリプトをアタッチして、Inspector上で設定するのも一つ。

using HUX.Buttons;
using UnityEngine;
using UnityEngine.Events;

public class ButtonAction : MonoBehaviour
{
    [SerializeField]
    private UnityEvent m_events = new UnityEvent();

    private void OnEnable()
    {
        var button = GetComponent<CompoundButton>();
        button.OnButtonReleased += ButtonReleased;
    }

    private void OnDisable()
    {
        var button = GetComponent<CompoundButton>();
        button.OnButtonReleased -= ButtonReleased;
    }

    private void ButtonReleased(GameObject obj)
    {
        Debug.Log("tapped!" + obj.name);
        m_events.Invoke();
    }
}

ObjectCollectionの設定変更を反映する

  • Object CollectionのパラメータをInspector上で変更したときは、Inspector末尾の「Update Collection」ボタンを押さないと反映されない。
  • 動的生成の場合はどうするんだろ・・

Curosrカーソルを入れ替える

  • MRDesignLabには3種類のカーソルが用意されている。(AnimCursor/SpriteCursor/LightCursor)
  • カーソルを入れ替えるには、HoloLens PrefabのHoloLens->FocusManager -> HoloLens FocuserのInputSourceFocuser.csのCursorPrefabにいずれかのPrefabを設定することで変更できる

  • またいずれのカーソルも、Cursor.csを継承して作成されている.

  • さらに注意点として、Cursor.cs/SpriteCursor.csともに、holotoolkitと、MRDesignLabに同名のスクリプトがあり、namespaceで分かれている。自分がどちらで制御しているか把握しながら開発しないと、ドハマリする可能性がある。

SpriteCursorをカスタマイズする

  • SpriteCursorは独自の画像を設定可能 64x64のpngを用意する
  • Inspector上でデフォルトで5種類の状態のスプライトを設定できる (デフォルトの-1と設定可能な0-5で全6種類)

f:id:pigshape:20170707190200p:plain

コードは以下の感じ

namespace HUX.Cursors
{
    /// <summary>
    /// This is the base cursor abstract class.
    /// </summary>
    public abstract class Cursor : MonoBehaviour
    {

        /// <summary>
        /// Enum for cursor states based on Shell support
        /// </summary>
        public enum CursorState
        {
            /// <summary>
            /// Useful for releasing external override.
            /// See <c>CursorState.Contextual</c>
            /// </summary>
            None = -1,
            /// <summary>
            /// not HandVisible
            /// </summary>
            Observe,
            /// <summary>
            /// HandVisible AND not IsFingerPressed AND CurrentInteractibleObject is NULL
            /// </summary>
            Interact,
            /// <summary>
            /// HandVisible AND not IsFingerPressed AND CurrentInteractibleObject exists
            /// </summary>
            Hover,
            /// <summary>
            /// HandVisible AND IsFingerPressed
            /// </summary>
            Select,
            /// <summary>
            /// Available for use by classes that extend Cursor.
            /// No logic for setting Release state exists in the base Cursor class.
            /// </summary>
            Release,
            /// <summary>
            /// Allows for external override
            /// </summary>
            Contextual  
        }

現在のカーソルを取得する

using HUX.Focus;

FocusManager.Instance.GazeFocuser.Cursor;

Suspendから復帰時にBoundingBoxが操作不能になる。

アプリを復帰した際に、BoundingBoxが動かせなくなる場合がある。

WorldCursor.csのSetCursorActiveで例外が発生。

原因は、WorldCursorなどに、Inputsourceが変更になってしまっているため。 (なんでそうなるのかはわからない。)

以下のようにWorldCursorのisEnabledのチェックを外すと発生しなくなる。

f:id:pigshape:20170803145023p:plain

参考