Доступ к состоянию ввода в MRTK — MRTK2
Можно напрямую запрашивать состояние всех входных данных в MRTK, выполняя итерацию контроллеров, подключенных к источникам входных данных. MRTK также предоставляет удобные методы для доступа к позиции и повороту глаз, рук, головы и контроллера движения.
Пример запроса входных данных см. в сцене InputDataExample с помощью итерации контроллеров и с помощью InputRayUtils
класса.
Пример: положение доступа, поворот головы, рук, глаз в MRTK
Класс MRTK InputRayUtils
предоставляет удобные методы доступа к лучу руки, лучу головы, лучу взгляда и лучам контроллера движения.
// Get the head ray
var headRay = InputRayUtils.GetHeadGazeRay();
// Get the right hand ray
Ray rightHandRay;
if(InputRayUtils.TryGetHandRay(Handedness.right, rightHandRay))
{
// Right hand ray is available
}
else
{
// Right hand ray is not available
}
Пример: положение доступа, поворот всех контроллеров 6DOF, активных в сцене
foreach(var controller in CoreServices.InputSystem.DetectedControllers)
{
// Interactions for a controller is the list of inputs that this controller exposes
foreach(MixedRealityInteractionMapping inputMapping in controller.Interactions)
{
// 6DOF controllers support the "SpatialPointer" type (pointing direction)
// or "GripPointer" type (direction of the 6DOF controller)
if (inputMapping.InputType == DeviceInputType.SpatialPointer)
{
Debug.Log("spatial pointer PositionData: " + inputMapping.PositionData);
Debug.Log("spatial pointer RotationData: " + inputMapping.RotationData);
}
if (inputMapping.InputType == DeviceInputType.SpatialGrip)
{
Debug.Log("spatial grip PositionData: " + inputMapping.PositionData);
Debug.Log("spatial grip RotationData: " + inputMapping.RotationData);
}
}
}