示例#1
0
        private void EnqueueMouseButtonEvent(MouseKey mouseKey, VK_State state)
        {
            VirtualKeyParameter lParam = ParameterPool.GetParameter <VirtualKeyParameter>();

            lParam.key = GetVirtualKeyMapData(mouseKey);
            GlobalEventQueue.EnQueueEvent(state, lParam);
        }
示例#2
0
        void Update()
        {
            for (int i = 0; i < keyMapList.Count; i++)
            {
                if (Input.GetKeyDown(keyMapList[i].keyboardKey))
                {
                    VirtualKeyParameter param = ParameterPool.GetParameter <VirtualKeyParameter>();
                    param.key = keyMapList[i].virtualKey;
                    GlobalEventQueue.EnQueueEvent(VK_State.Down, param);
                }

                if (Input.GetKey(keyMapList[i].keyboardKey))
                {
                    VirtualKeyParameter param = ParameterPool.GetParameter <VirtualKeyParameter>();
                    param.key = keyMapList[i].virtualKey;
                    GlobalEventQueue.EnQueueEvent(VK_State.Press, param);
                }

                if (Input.GetKeyUp(keyMapList[i].keyboardKey))
                {
                    VirtualKeyParameter param = ParameterPool.GetParameter <VirtualKeyParameter>();
                    param.key = keyMapList[i].virtualKey;
                    GlobalEventQueue.EnQueueEvent(VK_State.Up, param);
                }
            }
        }
示例#3
0
 /// <summary>
 /// 모든 이벤트들을 순서대로 빼내어서 등록된 리스너들을 실행한다.
 /// </summary>
 void Update()
 {
     for ( ; eventQueue.Count != 0;)
     {
         GlobalEventParameter p       = eventQueue.Dequeue();
         UnityAction <object> founded = null;
         if (listeners.TryGetValue(p.eventName, out founded))
         {
             founded.Invoke(p.value);
             ParameterPool.ReturnPool(p);
             if (null != p.value)
             {
                 ParameterPool.ReturnPool(p.value);
                 p.value = null;
             }
         }
         else
         {
             //UnityEngine.Debug.LogFormat( "{0}, {1} is not contain at listener" , p.eventName , p.value );
         }
     }
 }
示例#4
0
        // Update is called once per frame
        void Update()
        {
            #region press
            if (Input.GetMouseButton(0))
            {
                EnqueueMouseButtonEvent(MouseKey.Left, VK_State.Press);
            }

            if (Input.GetMouseButton(1))
            {
                EnqueueMouseButtonEvent(MouseKey.Right, VK_State.Press);
            }

            if (Input.GetMouseButton(2))
            {
                EnqueueMouseButtonEvent(MouseKey.Wheel, VK_State.Press);
            }
            #endregion

            #region Up
            if (Input.GetMouseButtonUp(0))
            {
                EnqueueMouseButtonEvent(MouseKey.Left, VK_State.Up);
            }

            if (Input.GetMouseButtonUp(1))
            {
                EnqueueMouseButtonEvent(MouseKey.Right, VK_State.Up);
            }

            if (Input.GetMouseButtonUp(2))
            {
                EnqueueMouseButtonEvent(MouseKey.Wheel, VK_State.Up);
            }
            #endregion

            #region Down
            if (Input.GetMouseButtonDown(0))
            {
                EnqueueMouseButtonEvent(MouseKey.Left, VK_State.Down);
            }

            if (Input.GetMouseButton(1))
            {
                EnqueueMouseButtonEvent(MouseKey.Right, VK_State.Down);
            }

            if (Input.GetMouseButton(2))
            {
                EnqueueMouseButtonEvent(MouseKey.Wheel, VK_State.Down);
            }

            #endregion
            float horizontal = Input.GetAxis("Mouse X");
            float vertical   = Input.GetAxis("Mouse Y");

            MouseKey whereDrag = MouseKey.None;


            if (horizontal != 0)
            {
                whereDrag = (horizontal > 0) ? MouseKey.RightDrag : MouseKey.LeftDrag;

                VirtualKeyParameter hParam = ParameterPool.GetParameter <VirtualKeyParameter>();
                hParam.key            = GetVirtualKeyMapData(whereDrag);
                hParam.additionalData = horizontal;

                GlobalEventQueue.EnQueueEvent(VK_State.Press, hParam);
            }

            if (vertical != 0)
            {
                whereDrag = (vertical > 0) ? MouseKey.UpDrag : MouseKey.DownDrag;

                VirtualKeyParameter vParam = ParameterPool.GetParameter <VirtualKeyParameter>();
                vParam.key            = GetVirtualKeyMapData(whereDrag);
                vParam.additionalData = vertical;

                GlobalEventQueue.EnQueueEvent(VK_State.Press, vParam);
            }
        }