private void Awake() { if (UnityEngine.XR.XRDevice.isPresent) { Destroy(gameObject); } Inputs = new List <GameObject>(); GameObject newRightInputSource = null; GameObject newLeftInputSource = null; switch (SourceType) { case InputSourceType.Hand: newRightInputSource = Instantiate(RightHand); if (SourceNumber == InputSourceNumber.Two) { newLeftInputSource = Instantiate(LeftHand); } break; } newRightInputSource.name = "Right " + SourceType.ToString(); newRightInputSource.transform.SetParent(transform); Inputs.Add(newRightInputSource); if (newLeftInputSource != null) { newLeftInputSource.name = "Left " + SourceType.ToString(); newLeftInputSource.transform.SetParent(transform); Inputs.Add(newLeftInputSource); } }
private void Awake() { bool spawnControllers = false; /* #if UNITY_2017_2_OR_NEWER * spawnControllers = !XRDevice.isPresent && XRSettings.enabled && simulateHandsInEditor; #else * spawnControllers = simulateHandsInEditor; #endif */ // Hack to enable mouse clicks // https://github.com/Microsoft/MixedRealityToolkit-Unity/issues/1537 spawnControllers = simulateHandsInEditor; if (spawnControllers) { sourceType = InputSourceType.Hand; sourceNumber = InputSourceNumber.Two; } if (!spawnControllers) { return; } switch (sourceType) { case InputSourceType.Hand: GameObject newRightInputSource = Instantiate(rightHand); newRightInputSource.name = "Right_" + sourceType.ToString(); newRightInputSource.transform.SetParent(transform); Inputs.Add(newRightInputSource); if (sourceNumber == InputSourceNumber.Two) { GameObject newLeftInputSource = Instantiate(leftHand); newLeftInputSource.name = "Left_" + sourceType.ToString(); newLeftInputSource.transform.SetParent(transform); Inputs.Add(newLeftInputSource); } break; case InputSourceType.Mouse: GameObject newMouseInputSource = Instantiate(mouse); newMouseInputSource.transform.SetParent(transform); Inputs.Add(newMouseInputSource); break; default: throw new ArgumentOutOfRangeException(); } }
private void Awake() { bool spawnControllers = false; #if UNITY_2017_2_OR_NEWER && !UNITY_STANDALONE_WIN spawnControllers = !XRDevice.isPresent && XRSettings.enabled && simulateHandsInEditor; #else spawnControllers = simulateHandsInEditor; #endif if (spawnControllers) { sourceType = InputSourceType.Hand; sourceNumber = InputSourceNumber.Two; } if (!spawnControllers) { return; } switch (sourceType) { case InputSourceType.Hand: GameObject newRightInputSource = Instantiate(rightHand); newRightInputSource.name = "Right_" + sourceType.ToString(); newRightInputSource.transform.SetParent(transform); Inputs.Add(newRightInputSource); if (sourceNumber == InputSourceNumber.Two) { GameObject newLeftInputSource = Instantiate(leftHand); newLeftInputSource.name = "Left_" + sourceType.ToString(); newLeftInputSource.transform.SetParent(transform); Inputs.Add(newLeftInputSource); } break; case InputSourceType.Mouse: GameObject newMouseInputSource = Instantiate(mouse); newMouseInputSource.transform.SetParent(transform); Inputs.Add(newMouseInputSource); break; default: throw new ArgumentOutOfRangeException(); } }
private void Awake() { bool spawnControllers = false; spawnControllers = Application.isEditor && simulateHandsInEditor; if (spawnControllers) { sourceType = InputSourceType.Hand; sourceNumber = InputSourceNumber.Two; } if (!spawnControllers) { return; } switch (sourceType) { case InputSourceType.Hand: GameObject newRightInputSource = Instantiate(rightHand); newRightInputSource.name = "Right_" + sourceType.ToString(); newRightInputSource.transform.SetParent(transform); Inputs.Add(newRightInputSource); if (sourceNumber == InputSourceNumber.Two) { GameObject newLeftInputSource = Instantiate(leftHand); newLeftInputSource.name = "Left_" + sourceType.ToString(); newLeftInputSource.transform.SetParent(transform); Inputs.Add(newLeftInputSource); } break; case InputSourceType.Mouse: GameObject newMouseInputSource = Instantiate(mouse); newMouseInputSource.transform.SetParent(transform); Inputs.Add(newMouseInputSource); break; default: throw new ArgumentOutOfRangeException(); } }