Esempio n. 1
0
        public void Capture()
        {
            for (int i = 0; i < Bindings.Keys.Length; i++)
            {
                Binding key        = Bindings.Keys[i];
                bool    keyPressed = Input.GetKey(key.Code);
                if (keyPressed == key.State)
                {
                    continue;
                }
                Bindings.Keys[i].State = keyPressed;
                if (!keyPressed && !Release.Contains(key.InteractionSubscription))
                {
                    continue;
                }
                if (keyPressed && !Press.Contains(key.InteractionSubscription))
                {
                    continue;
                }
                Interaction interaction = keyPressed ? Interaction.Pressed : Interaction.Released;
                switch (key.Type)
                {
                case InputType.Key:
                    OnKeyEvent?.Invoke(new KeyEvent(interaction, key.Action));
                    break;

                case InputType.Mouse:
                    OnPointerEvent?.Invoke(new PointerEvent(interaction, key.Action, Input.mousePosition));
                    break;

                default:
                    throw new System.Exception("Unhandled input binding type: " + key.Type);
                }
            }
        }
 /// <summary>
 /// THe pointer has clicked the element
 /// </summary>
 /// <param name="eventData"></param>
 public void OnPointerClick(PointerEventData eventData)
 {
     OnPointerEvent?.Invoke(EPointerEvent.Click);
     OnClickEvent?.Invoke();
 }
 /// <summary>
 /// IPointerUpHandler function
 /// </summary>
 /// <param name="eventData"></param>
 public void OnPointerUp(PointerEventData eventData) => OnPointerEvent?.Invoke(EPointerEvent.Up);
 /// <summary>
 /// IPointerExitHandler function
 /// </summary>
 /// <param name="eventData"></param>
 public void OnPointerExit(PointerEventData eventData) => OnPointerEvent?.Invoke(EPointerEvent.Exit);
 /// <summary>
 /// IPointerEnterHandler function
 /// </summary>
 /// <param name="eventData"></param>
 public void OnPointerEnter(PointerEventData eventData) => OnPointerEvent?.Invoke(EPointerEvent.Enter);
 /// <summary>
 /// IPointerDownHandler function
 /// </summary>
 /// <param name="eventData"></param>
 public void OnPointerDown(PointerEventData eventData) => OnPointerEvent?.Invoke(EPointerEvent.Down);
 public void OnPointerDown(PointerEventData eventData)
 {
     onPointerDown.Invoke(this, eventData);
 }
 public void OnPointerUp(PointerEventData eventData)
 {
     onPointerUp.Invoke(this, eventData);
 }
 public void OnPointerExit(PointerEventData eventData)
 {
     onPointerExit.Invoke(this, eventData);
 }