Пример #1
0
        private void Awake()
        {
            behaviour = new MBehaviour(ExecutionPriority.Highest, -900, enabled);

            behaviour.OnAwake(() =>
            {
                InputHands = new Dictionary <int, MInputHand>();

                //初始化手的种类
                var handUI    = MHandUIManager.CreateHandUI(transform, handSprite, handSize);
                var inputHand = new MInputHand(0, handUI, OperatePlatform.Mouse);

                InputHands.Add(0, inputHand);

                isPlaying = true;

                //注册操作者相关事件
                var operate = MOperateManager.AddOperateHand(inputHand);
                //注册方法
                operate.OnGrab    = OnGrabObject;
                operate.OnSetGrab = SetGrabObject;
                operate.OnEnable();
            });

            behaviour.OnUpdate(OnMouseUpdate);

            MBehaviourController.AddBehaviour(behaviour);
        }
Пример #2
0
        void KinectMInputInitialize(KinectActiveHandStadus kinectActiveHandStadus)
        {
            InputHands = new Dictionary <int, MInputHand>();
            switch (kinectActiveHandStadus)
            {
            case KinectActiveHandStadus.None:
                throw new Exception("单双手状态未选择");

            case KinectActiveHandStadus.One:
                //初始化手的种类
                var handUI    = MHandUIManager.CreateHandUI(transform, rightHandSprite, handSize);
                var inputHand = new MInputHand(0, handUI, OperatePlatform.Kinect);
                InputHands.Add(0, inputHand);

                isPlaying = true;

                //注册操作者相关事件
                var operate = MOperateManager.AddOperateHand(inputHand, this);
                //注册方法
                operate.OnGrab    = OnRightGrabObject;
                operate.OnSetGrab = SetGrabObject;
                operate.OnEnable();

                break;

            case KinectActiveHandStadus.Two:
                //初始化手的种类
                var rightHandUI    = MHandUIManager.CreateHandUI(transform, rightHandSprite, handSize);
                var rightInputHand = new MInputHand(0, rightHandUI, OperatePlatform.Kinect);
                InputHands.Add(0, rightInputHand);

                var leftHandUI    = MHandUIManager.CreateHandUI(transform, leftHandSprite, handSize);
                var leftInputHand = new MInputHand(1, leftHandUI, OperatePlatform.Kinect);
                InputHands.Add(1, leftInputHand);

                isPlaying = true;

                //注册操作者相关事件
                var rightOperate = MOperateManager.AddOperateHand(rightInputHand, this);
                //注册方法
                rightOperate.OnGrab    = OnRightGrabObject;
                rightOperate.OnSetGrab = SetGrabObject;
                rightOperate.OnEnable();

                //注册操作者相关事件
                var leftOperate = MOperateManager.AddOperateHand(leftInputHand, this);
                //注册方法
                leftOperate.OnGrab    = OnLeftGrabObject;
                leftOperate.OnSetGrab = SetGrabObject;
                leftOperate.OnEnable();
                break;

            default:
                break;
            }
        }
Пример #3
0
        /// <summary>
        /// Kinect控制端数据初始化
        /// </summary>
        /// <param name="handModel">Hand model.</param>
        private void KinectInitialize(KinectHandModel handModel)
        {
            InputHands = new Dictionary <int, MInputHand>();

            inputKinect = gameObject.GetComponent <MInputKinect>() ?? gameObject.AddComponent <MInputKinect>();

            MInputKinect.HandModel = handModel;
            IsPlaying = true;

            //实例化右手
            var rightHandUI    = MHandUIManager.CreateHandUI(transform, rightHandOperate.handIcon);
            var rightInputHand = new MInputHand(rightHandOperate.HandIndex, rightHandUI, OperatePlatform.Kinect);

            rightHandUI.name = "kinect-Hand-0";
            InputHands.Add(rightHandOperate.HandIndex, rightInputHand);

            //实例化左手
            var leftHandUI    = MHandUIManager.CreateHandUI(transform, leftHandOperate.handIcon);
            var leftInputHand = new MInputHand(leftHandOperate.HandIndex, leftHandUI, OperatePlatform.Kinect);

            leftHandUI.name = "Kinect-Hand-1";
            InputHands.Add(leftHandOperate.HandIndex, leftInputHand);

            //右手操作端相关初始化与事件绑定
            rightHandOperate.Operate = MOperateManager.AddOperateHand(rightInputHand, this);
            rightHandOperate.BindGrab();

            //左手操作端相关初始化与事件的绑定
            leftHandOperate.Operate = MOperateManager.AddOperateHand(leftInputHand, this);
            leftHandOperate.BindGrab();

            IsEnable = true;

            //mouseController = gameObject.GetComponent<MouseController>() ?? gameObject.AddComponent<MouseController>();
            //mouseController.IsEnable = false;

            //检查一次是否激活手
            HandStop(2);//默认也禁止
        }
Пример #4
0
        private void Awake()
        {
            behaviour = new MBehaviour(ExecutionPriority.Highest, -900, enabled);

            InputHands = new Dictionary <int, MInputHand>();

            //初始化手的种类
            var handUI    = MHandUIManager.CreateHandUI(transform, handSprite, handSize);
            var inputHand = new MInputHand(0, handUI, OperatePlatform.Mouse);

            handUI.name = "Mouse-Hand";

            InputHands.Add(0, inputHand);

            isPlaying = true;

            //注册操作者相关事件
            operate = MOperateManager.AddOperateHand(inputHand, this);
            //注册方法
            operate.OnGrab    = OnGrabObject;
            operate.OnSetGrab = SetGrabObject;

            IsEnable = true;
        }