本日はMRDLの[Surfaces]の調査枠です。
前回[FingerSurface]クラスを見ました。
コード全文は次の様になっています。
この[FingerSurface]クラスではユーザーのFingerTipの情報を取得しメニュー操作時には物理挙動をなくすなどの処理を行っています。
[HandSurface]クラスは[FingerSurface]クラスから派生するサブクラスです。
using Microsoft.MixedReality.Toolkit;
using Microsoft.MixedReality.Toolkit.Input;
using Microsoft.MixedReality.Toolkit.Utilities;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class HandSurface : FingerSurface
{
...
}
今回はこの[HandSurface]クラスがどのような事を行っているかに関して調べていきます。
〇HandSurfaceクラス
前述のとおり[HandSurface]クラスは[FingerSurface]クラスから派生するサブクラスです。
Unityinspectorウィンドウに表示されるプロパティは以下のように[FingerSurface]クラスに定義されている[protected]な変数も表示されます。

[HandSurface]で定義されている変数は次のようになります。
[Header("Joint objects")]
[SerializeField]
protected Transform[] handJoints;
[SerializeField]
protected Rigidbody[] handJointRigidBodies;
[SerializeField]
protected Collider[] handJointColliders;
[HandSurface]クラスの関数は次のようになります。
protected override void LateUpdate()
{
...
#region hand tracking
...
#endregion
}
protected override void FixedUpdate()
{
...
#region physics
...
#endregion
}
#if UNITY_EDITOR
[MenuItem("Surfaces/GenerateHandJoints")]
private static void GenerateHandJoints()
{
...
}
#endif
[LateUpdate()]はUpdate関数の後に実行されるUpdateの処理です。また[FixedUpdate()]は物理変化の後などに実行される処理です。こちらはFPSと処理が同期していないことに注意が必要です。
#if UNITY_EDITOR
[MenuItem("Surfaces/GenerateHandJoints")]
private static void GenerateHandJoints()
{
...
}
#endif
これはUnityEditor上で実行する場合にのみ処理がじっこうされ実機コンパイル時には除外されるコードになります。
以上が[HandSurface]のざっくりとした中身です。次回以降処理を具体的に見ていきます。