예제 #1
0
        private int SetInputSource(InputSourceType sourceType, InputSourceNumber sourceNumber)
        {
            byte[] msgData = new byte[]
            {
                0x07,
                0x01,
                (byte)MessageSet.InputSourceSet,
                (byte)sourceType,
                (byte)sourceNumber,
                0x01,
                0x00,
                0x00
            };

            byte[] responseData = null;

            if (this.SendMessage(msgData, ref responseData) == 0)
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }
        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();
            }
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
        private int GetCurrentSource()
        {
            byte[] msgData = new byte[]
            {
                0x03,
                0x01,
                (byte)MessageSet.CurrentSourceGet,
                0x00
            };

            byte[] msgReport = null;

            if (this.SendMessage(msgData, ref msgReport) == 0)
            {
                this.currentSource = (InputSourceNumber)msgReport[2];

                return(0);
            }
            else
            {
                return(1);
            }
        }