private void DrawHandsGUI() { HandSimulationMode newHandSimMode = (HandSimulationMode)EditorGUILayout.EnumPopup("Hand Simulation Mode", SimulationService.HandSimulationMode); if (newHandSimMode != SimulationService.HandSimulationMode) { SimulationService.HandSimulationMode = newHandSimMode; } using (new GUILayout.HorizontalScope()) { DrawHandGUI( "Left", SimulationService.IsAlwaysVisibleHandLeft, v => SimulationService.IsAlwaysVisibleHandLeft = v, SimulationService.HandPositionLeft, v => SimulationService.HandPositionLeft = v, SimulationService.HandRotationLeft, v => SimulationService.HandRotationLeft = v, SimulationService.ResetHandLeft); DrawHandGUI( "Right", SimulationService.IsAlwaysVisibleHandRight, v => SimulationService.IsAlwaysVisibleHandRight = v, SimulationService.HandPositionRight, v => SimulationService.HandPositionRight = v, SimulationService.HandRotationRight, v => SimulationService.HandRotationRight = v, SimulationService.ResetHandRight); } }
protected SimulatedHand GetOrAddHandDevice(Handedness handedness, HandSimulationMode simulationMode) { var controller = GetHandDevice(handedness); if (controller != null) { if (controller.SimulationMode == simulationMode) { return(controller); } else { // Remove and recreate hand device if simulation mode doesn't match RemoveHandDevice(handedness); } } SupportedControllerType st = simulationMode == HandSimulationMode.Gestures ? SupportedControllerType.GGVHand : SupportedControllerType.ArticulatedHand; IMixedRealityPointer[] pointers = RequestPointers(st, handedness); var inputSource = Service?.RequestNewGenericInputSource($"{handedness} Hand", pointers, InputSourceType.Hand); switch (simulationMode) { case HandSimulationMode.Articulated: controller = new SimulatedArticulatedHand(TrackingState.Tracked, handedness, inputSource); break; case HandSimulationMode.Gestures: controller = new SimulatedGestureHand(TrackingState.Tracked, handedness, inputSource); break; default: controller = null; break; } System.Type controllerType = simulationMode == HandSimulationMode.Gestures ? typeof(SimulatedGestureHand) : typeof(SimulatedArticulatedHand); if (controller == null || !controller.Enabled) { // Controller failed to be setup correctly. Debug.LogError($"Failed to create {controllerType} controller"); // Return null so we don't raise the source detected. return(null); } for (int i = 0; i < controller.InputSource?.Pointers?.Length; i++) { controller.InputSource.Pointers[i].Controller = controller; } Service?.RaiseSourceDetected(controller.InputSource, controller); trackedHands.Add(handedness, controller); UpdateActiveControllers(); return(controller); }
internal static void SetHandSimulationMode(HandSimulationMode mode) { var iss = GetInputSimulationService(); var isp = ScriptableObject.CreateInstance <MixedRealityInputSimulationProfile>(); isp.HandSimulationMode = mode; iss.InputSimulationProfile = isp; }
// Register input sources for hands based on hand data protected void UpdateHandDevice(HandSimulationMode simulationMode, Handedness handedness, SimulatedHandData handData) { if (handData != null && handData.IsTracked) { SimulatedHand controller = GetOrAddHandDevice(handedness, simulationMode); controller.UpdateState(handData); } else { RemoveHandDevice(handedness); } }
public static void SetHandSimulationMode(HandSimulationMode mode) { var iss = GetInputSimulationService(); iss.HandSimulationMode = mode; }