// Update is called once per frame
    void Update()
    {
        //Debug.Log("Input.mousePosition = >" + Input.mousePosition);
        //Debug.Log("Screen.width = >" + Screen.width);
        //Debug.Log("Screen.height = >" + Screen.height);
        //
        _axis_Horizontal = Input.GetAxis("Horizontal");
        _axis_Vertical   = Input.GetAxis("Vertical");
        //
        #region Input.GetAxis("Horizontal"),Input.GetAxis("Vertical")
        if (isHorizontalOrVerticalAxisChanged)
        {
            //Debug.Log("h = " + HorizontalAxisCurrentFrame + "," + "v = " + VerticalAxisCurrentFrame);
            //Debug.Log("Horizontal = " + Input.GetAxis("Horizontal") + "," + "Vertical = " + Input.GetAxis("Vertical"));
            if (!isHorizontalAxisChanged)
            {
                //Debug.Log("v = " + VerticalAxisCurrentFrame);
                if (EventGetAxis_Vertical != null)
                {
                    EventGetAxis_Vertical.Invoke(Axis_Vertical);
                }
            }
            else if (!isVerticalAxisChanged)
            {
                //Debug.Log("h = " + HorizontalAxisCurrentFrame);
                if (EventGetAxis_Horizontal != null)
                {
                    EventGetAxis_Horizontal.Invoke(Axis_Horizontal);
                }
            }
            else
            {
                //Debug.Log("h = " + Axis_Horizontal + "," + "v = " + Axis_Vertical);
                //Debug.Log("Horizontal = " + Input.GetAxis("Horizontal") + "," + "Vertical = " + Input.GetAxis("Vertical"));
                //
                if (EventGetAxis_HorizontalVertical != null)
                {
                    EventGetAxis_HorizontalVertical.Invoke(Axis_Horizontal, Axis_Vertical);
                }
            }
        }
        #endregion
        //
        #region Input.GetAxis("Mouse ScrollWheel")
        if (EventGetAxis_MouseScrollWheel != null)
        {
            _axis_MouseScrollWheel = Input.GetAxis("Mouse ScrollWheel");
            if (isAxisMouseScrollWheelChanged)
            {
                EventGetAxis_MouseScrollWheel.Invoke(Axis_MouseScrollWheel);
            }
        }
        #endregion

        #region Input.GetAxis("Mouse X")&Input.GetAxis("Mouse Y")
        if (EventGetAxis_MouseXMouseY != null)
        {
            _axis_MouseX = Input.GetAxis("Mouse X");
            _axis_MouseY = Input.GetAxis("Mouse Y");
            //
            if (isAxisMouseXYChanged)
            {
                EventGetAxis_MouseXMouseY.Invoke(Axis_MouseX, Axis_MouseY);
            }
        }
        #endregion
        //
        #region GetKey check
        if (Input.anyKey && IsInputWork)
        {
            //Debug.Log("Input.anyKey");
            KeyCode[] keyCodes = new KeyCode[EventDict_GetKey.Keys.Count];
            EventDict_GetKey.Keys.CopyTo(keyCodes, 0);
            for (int i = 0; i < keyCodes.Length; i++)
            {
                KeyCode keyCode = keyCodes[i];
                if (Input.GetKey(keyCode))
                {
                    if (EventDict_GetKey[keyCode] != null)
                    {
                        EventDict_GetKey[keyCode].Invoke(keyCode);
                    }
                }
            }
            //
        }
        #endregion
        //
        #region GetKeyDown check
        if (Input.anyKeyDown)//Including mouse click
        {
            //Debug.Log("Input.anyKeyDown");
            KeyCode[] keyCodes = new KeyCode[EventDict_GetKeyDown.Keys.Count];
            EventDict_GetKeyDown.Keys.CopyTo(keyCodes, 0);
            for (int i = 0; i < keyCodes.Length; i++)
            {
                KeyCode keyCode = keyCodes[i];
                //
                if (Input.GetKeyDown(keyCode))
                {
                    if (EventDict_GetKeyDown[keyCode] != null)
                    {
                        //Debug.LogError(keyCode + "    is Down");
                        EventDict_GetKeyDown[keyCode].Invoke(keyCode);
                    }

                    if (FlagDict_IsKeyDown.ContainsKey(keyCode))
                    {
                        keyCodeDownUpStatusBinding(keyCode, true);
                    }
                }
            }
            //
        }
        #endregion
        //
        #region GetKeyUp check
        //Debug.Log("GetKeyUp check");
        //
        KeyCode[] keyCodesArr = new KeyCode[EventDict_GetKeyUp.Keys.Count];
        EventDict_GetKeyUp.Keys.CopyTo(keyCodesArr, 0);
        for (int i = 0; i < keyCodesArr.Length; i++)
        {
            KeyCode keyCode = keyCodesArr[i];
            //
            if (FlagDict_IsKeyDown.ContainsKey(keyCode))
            {
                if (FlagDict_IsKeyDown[keyCode] && !Input.GetKey(keyCode))
                {
                    keyCodeDownUpStatusBinding(keyCode, false);
                    if (EventDict_GetKeyUp[keyCode] != null)
                    {
                        //Debug.LogError(keyCode + "    is Up");
                        EventDict_GetKeyUp[keyCode].Invoke(keyCode);
                    }
                }
            }
            //
        }
        //
        #endregion
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log("Input.mousePosition = >" + Input.mousePosition);
        //Debug.Log("Screen.width = >" + Screen.width);
        //Debug.Log("Screen.height = >" + Screen.height);
        //
        _axis_Horizontal = Input.GetAxis("Horizontal");
        _axis_Vertical   = Input.GetAxis("Vertical");
        //
        #region Input.GetAxis("Horizontal"),Input.GetAxis("Vertical")
        if (isHorizontalOrVerticalAxisChanged)
        {
            //Debug.Log("h = " + HorizontalAxisCurrentFrame + "," + "v = " + VerticalAxisCurrentFrame);
            //Debug.Log("Horizontal = " + Input.GetAxis("Horizontal") + "," + "Vertical = " + Input.GetAxis("Vertical"));
            if (!isHorizontalAxisChanged)
            {
                //Debug.Log("v = " + VerticalAxisCurrentFrame);
                if (EventGetAxis_Vertical != null)
                {
                    EventGetAxis_Vertical.Invoke(Axis_Vertical);
                }
            }
            else if (!isVerticalAxisChanged)
            {
                //Debug.Log("h = " + HorizontalAxisCurrentFrame);
                if (EventGetAxis_Horizontal != null)
                {
                    EventGetAxis_Horizontal.Invoke(Axis_Horizontal);
                }
            }
            else
            {
                //Debug.Log("h = " + Axis_Horizontal + "," + "v = " + Axis_Vertical);
                //Debug.Log("Horizontal = " + Input.GetAxis("Horizontal") + "," + "Vertical = " + Input.GetAxis("Vertical"));
                //
                if (EventGetAxis_HorizontalVertical != null)
                {
                    EventGetAxis_HorizontalVertical.Invoke(Axis_Horizontal, Axis_Vertical);
                }
            }
        }
        #endregion
        //
        #region Input.GetAxis("Mouse ScrollWheel")
        if (EventGetAxis_MouseScrollWheel != null)
        {
            _axis_MouseScrollWheel = Input.GetAxis("Mouse ScrollWheel");
            if (isAxisMouseScrollWheelChanged)
            {
                EventGetAxis_MouseScrollWheel.Invoke(Axis_MouseScrollWheel);
            }
        }
        #endregion

        #region Input.GetAxis("Mouse X")&Input.GetAxis("Mouse Y")
        if (EventGetAxis_MouseXMouseY != null)
        {
            _axis_MouseX = Input.GetAxis("Mouse X");
            _axis_MouseY = Input.GetAxis("Mouse Y");
            if (isAxisMouseXYChanged)
            {
                EventGetAxis_MouseXMouseY.Invoke(Axis_MouseX, Axis_MouseY);
            }
        }
        #endregion
        //
        #region GetKey check
        if (Input.anyKey)
        {
            //Debug.Log("Input.anyKey");
            foreach (KeyCode keyCode in EventDict_GetKey.Keys)
            {
                if (Input.GetKey(keyCode))
                {
                    if (EventDict_GetKey[keyCode] != null)
                    {
                        EventDict_GetKey[keyCode].Invoke();
                    }
                }
            }
        }
        #endregion
        //
        #region GetKeyDown check
        if (Input.anyKeyDown)//Including mouse click
        {
            //Debug.Log("Input.anyKeyDown");
            foreach (KeyCode keyCode in EventDict_GetKeyDown.Keys)
            {
                if (Input.GetKeyDown(keyCode))
                {
                    if (EventDict_GetKeyDown[keyCode] != null)
                    {
                        //Debug.LogError(keyCode + "    is Down");
                        EventDict_GetKeyDown[keyCode].Invoke();
                    }

                    if (FlagDict_IsKeyDown.ContainsKey(keyCode))
                    {
                        keyCodeDownUpStatusBinding(keyCode, true);
                    }
                }
            }
        }
        #endregion
        //
        #region GetKeyUp check
        foreach (KeyCode keyCode in EventDict_GetKeyUp.Keys)
        {
            if (Input.GetKeyUp(keyCode))
            {
                if (EventDict_GetKeyUp[keyCode] != null)
                {
                    //Debug.LogError(keyCode + "    is Up");
                    EventDict_GetKeyUp[keyCode].Invoke();
                }

                if (FlagDict_IsKeyDown.ContainsKey(keyCode))
                {
                    keyCodeDownUpStatusBinding(keyCode, false);
                }
            }
        }
        #endregion

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            //Application.Quit();
        }
    }