5 using System.Collections.Generic;
7 #if UNITY_2017_2_OR_NEWER 20 private enum InputSourceType
26 private enum InputSourceNumber
33 private bool simulateHandsInEditor =
true;
36 private InputSourceType sourceType;
39 private InputSourceNumber sourceNumber;
41 public List<GameObject> Inputs =
new List<GameObject>(0);
44 private GameObject mouse = null;
47 private GameObject leftHand = null;
50 private GameObject rightHand = null;
54 bool spawnControllers =
false;
56 #if UNITY_2017_2_OR_NEWER 57 spawnControllers = !XRDevice.isPresent && XRSettings.enabled && simulateHandsInEditor;
59 spawnControllers = simulateHandsInEditor;
63 sourceType = InputSourceType.Hand;
64 sourceNumber = InputSourceNumber.Two;
67 if (!spawnControllers) {
return; }
71 case InputSourceType.Hand:
72 GameObject newRightInputSource = Instantiate(rightHand);
74 newRightInputSource.name =
"Right_" + sourceType.ToString();
75 newRightInputSource.transform.SetParent(transform);
76 Inputs.Add(newRightInputSource);
78 if (sourceNumber == InputSourceNumber.Two)
80 GameObject newLeftInputSource = Instantiate(leftHand);
81 newLeftInputSource.name =
"Left_" + sourceType.ToString();
82 newLeftInputSource.transform.SetParent(transform);
83 Inputs.Add(newLeftInputSource);
86 case InputSourceType.Mouse:
87 GameObject newMouseInputSource = Instantiate(mouse);
88 newMouseInputSource.transform.SetParent(transform);
89 Inputs.Add(newMouseInputSource);
93 throw new ArgumentOutOfRangeException();