HandleCharEvent() public method

public HandleCharEvent ( UnityEngine ev ) : bool
ev UnityEngine
return bool
Ejemplo n.º 1
0
    /// <summary>
    /// User Input Events such as Mouse/Key/Touch are obtained from Unity and passed to Scaleform in this function.
    /// </summary>
    protected virtual void SFOnGUI()
    {
        if (SFMgr == null) return;

        // Process touch events:
        if (InputManager.TouchCount > 0)
        {
            for (int i = 0; i < InputManager.TouchCount; i++)
            {
                Touch touch = InputManager.GetTouch(i);
                SFMgr.HandleTouchEvent(touch);
            }
        }

        Vector2 mousePos;

        // Get Time since last frame: keep in mind the following from Unity Doc
        // Note that you should not rely on Time.deltaTime from inside OnGUI since
        // OnGUI can be called multiple times per frame and deltaTime would hold the
        // same value each call, until next frame where it would be updated again.
        // float deltaTime = Time.deltaTime;
        // Check if the mouse moved:
		
        mousePos = Event.current.mousePosition;
        if ((mousePos[0] != LastMousePos[0]) || (mousePos[1] != LastMousePos[1]))
        {
            SFMgr.HandleMouseMoveEvent(mousePos[0], mousePos[1]);
            LastMousePos[0] = mousePos[0]; LastMousePos[1] = mousePos[1];
        }

        switch (Event.current.type)
        {
            case EventType.MouseMove:
                break;
            case EventType.MouseDown:
                SFMgr.HandleMouseDownAndUpEvent(Event.current);
                break;
            case EventType.MouseUp:
                SFMgr.HandleMouseDownAndUpEvent(Event.current);
                break;
			case EventType.ScrollWheel:
				SFMgr.HandleMouseWheelEvent(Event.current);
				break;
            case EventType.KeyDown:
                if (Event.current.isKey && Event.current.keyCode != KeyCode.None)
                {
                    SFMgr.HandleKeyDownEvent(Event.current);
                }

                if (Event.current.isKey && Event.current.character != 0)
                {
                    SFMgr.HandleCharEvent(Event.current);
                }
                break;
            case EventType.KeyUp:
                if (Event.current.isKey && Event.current.keyCode != KeyCode.None)
                {
                    SFMgr.HandleKeyUpEvent(Event.current);
                }
                break;

            case EventType.Repaint:			
				HandleKeyModifier(Event.current, ref ShiftKeyDown, EventModifiers.Shift, KeyCode.LeftShift);
				HandleKeyModifier(Event.current, ref ControlKeyDown, EventModifiers.Control, KeyCode.LeftControl);
				HandleKeyModifier(Event.current, ref AltKeyDown, EventModifiers.Alt, KeyCode.LeftAlt);
                break;
        }
    }