예제 #1
0
        public void SetupKeyPass(KeyCode hold)
        {
            Action <int> Key     = (index) => { };
            Action <int> KeyUp   = (index) => { };
            Action <int> KeyDown = (index) => { };


            KeyUpEventPass[0] += KeyUp = (index) => {
                if (Input.GetKeyDown(hold))
                {
                    GuiElementDefs.HandleEvent(eventname: EventModel.EVENT_KEY_DOWN, keycode: hold);
                    KeyDownEventPass[index] += KeyDown;
                }
                else
                {
                    KeyUpEventPass[index] += KeyUp;
                }
            };

            KeyDown = (index) => {
                if (Input.GetKeyUp(hold))
                {
                    GuiElementDefs.HandleEvent(eventname: EventModel.EVENT_KEY_UP, keycode: hold);
                    KeyUpEventPass[index] += KeyUp;
                }
                else
                {
                    KeyDownEventPass[index] += KeyDown;
                    GuiElementDefs.HandleEvent(eventname: EventModel.EVENT_KEY, keycode: hold);
                }
            };
        }
예제 #2
0
        public void Update()
        {
            //Debug.Log("Run");

            mousehits.Clear();

            mousehits = InputMethods.MousePickedObjects(Camera.main);

            int mouseButton     = 0;
            int mouseButtonDown = 0;
            int mouseButtonUp   = 0;

            if (mousehits.Count > 0)
            {
                //Debug.Log(go.layer + ":" + go.name);


                for (int i = 0; i < 7; i++)
                {
                    if (Input.GetMouseButtonDown(i))
                    {
                        mouseButtonDown += 1 << (i);
                    }
                    else if (Input.GetMouseButtonUp(i))
                    {
                        mouseButtonUp += 1 << (i);
                    }
                    else if (Input.GetMouseButton(i))
                    {
                        mouseButton += 1 << (i);
                    }
                }

                foreach (GameObject go in mousehits.Values)
                {
                    if (mouseButton != 0)
                    {
                        //Debug.Log(go.name + ":" + ElementDefs.ElementEventMap.ContainsKey(go.name));
                        GuiElementDefs.HandleEvent(eventname: EventModel.EVENT_MOUSE, indexname: go.name, mousebutton: mouseButton);
                    }

                    if (mouseButtonDown != 0)
                    {
                        //Debug.Log(go.name + ":" + ElementDefs.ElementEventMap.ContainsKey(go.name));
                        GuiElementDefs.HandleEvent(eventname: EventModel.EVENT_MOUSE_DOWN, indexname: go.name, mousebutton: mouseButtonDown);
                    }

                    if (mouseButtonUp != 0)
                    {
                        //Debug.Log(go.name + ":" + ElementDefs.ElementEventMap.ContainsKey(go.name));
                        GuiElementDefs.HandleEvent(eventname: EventModel.EVENT_MOUSE_UP, indexname: go.name, mousebutton: mouseButtonUp);
                    }
                }
            }

            if ((mouseButton + mouseButtonDown + mouseButtonUp) == 0)
            {
                //Debug.Log("started");
                int currentKeyIndex = KeyEventIndex;

                if (KeyEventIndex == 0)
                {
                    KeyEventIndex = 1;
                }
                else
                {
                    KeyEventIndex = 0;
                }

                KeyUpEventPass[currentKeyIndex](KeyEventIndex);
                KeyDownEventPass[currentKeyIndex](KeyEventIndex);

                KeyUpEventPass[currentKeyIndex]   = (index) => { };
                KeyDownEventPass[currentKeyIndex] = (index) => { };
            }
        }