示例#1
0
    public void Click(Controller sender)
    {
        if (owner == GameSettings.mainPlayer || owner == null)
        {
            privateOnClick.Invoke();
        }
        else
        {
            switch (owner.controlType)
            {
            case Controller.ControlType.MOUSE:
            case Controller.ControlType.TOUCHSCREEN:
            case Controller.ControlType.ALGORITHM:
            case Controller.ControlType.NEURAL_NETWORK:
            {
                privateOnClick.Invoke();
                break;
            }

            case Controller.ControlType.GAMEPAD:
            case Controller.ControlType.KEYBOARD:
            {
                if (owner == sender)
                {
                    privateOnClick.Invoke();
                }
                break;
            }
            }
        }
    }
    private IEnumerator PressButton()
    {
        float timer = 0;

        isPressing = true;

        while (timer < pressTime)
        {
            timer += Time.deltaTime;
            float distance = -pressSpeed * Time.deltaTime;
            transform.Translate(new Vector3(distance * xMove, distance * yMove, distance * zMove));
            yield return(new WaitForEndOfFrame());
        }

        pressEvent.Invoke();

        if (eventTriggerRate > 0)
        {
            while (true)
            {
                pressEvent.Invoke();
                yield return(new WaitForSeconds(eventTriggerRate));
            }
        }
    }
示例#3
0
 public override void OnPointerEnter(PointerEventData eventData)
 {
     base.OnPointerEnter(eventData);
     if (Panel.mouseButton)
     {
         onSelfClick?.Invoke();
     }
 }
示例#4
0
 public virtual void OnPointerClick(PointerEventData eventData)
 {
     if (IsActive() && IsInteractable())
     {
         if (eventData.button == PointerEventData.InputButton.Left)
         {
             m_OnClick.Invoke();
         }
     }
 }
示例#5
0
    private void ButtonRelease()
    {
        if (!IsActive() || !IsInteractable())
        {
            return;
        }

        UISystemProfilerApi.AddMarker("Button.onRelease", this);
        m_OnRelease.Invoke();
    }
示例#6
0
 public override void OnPointerUp(PointerEventData eventData)
 {
     // 指針擡起,結束開始長按
     base.OnPointerUp(eventData);
     my_isStartPress = false;
     if (my_longPressTrigger && !my_longPressEndTrigger && my_onLongPressEnd != null)
     {
         my_onLongPressEnd.Invoke();
         my_longPressEndTrigger = true;
     }
 }
示例#7
0
    public virtual void OnPointerUp(PointerEventData eventData)
    {
        if (eventData.button != PointerEventData.InputButton.Left)
        {
            return;
        }

        m_pointerPressed = false;
        Unpress();
        if (m_pointerInside)
        {
            m_OnClick.Invoke();
        }
    }
示例#8
0
 protected void LeftMouseUpEventHandler(object sender, MouseEventArgs args)
 {
     if (_mouseOver && ButtonClickedEvent != null)
     {
         ButtonClickedEvent.Invoke(this, new ButtonEventArgs(this));
     }
 }
示例#9
0
 public void Draw()
 {
     if (GUI.Button(m_Rect, m_Label))
     {
         m_OnClick.Invoke();
     }
 }
示例#10
0
 public override void OnPointerUp(PointerEventData eventData)
 {
     base.OnPointerUp(eventData);
     CancelInvoke("LongPressTimer");
     m_OnRelease.Invoke();
     m_LongPressFrame = m_LongPressState > 1 ? Time.frameCount : 0;
 }
示例#11
0
 public override void OnPointerExit(PointerEventData eventData)
 {
     m_LongPressState = m_LongPressState == 2 ? 3 : -1;
     CancelInvoke("LongPressTimer");
     base.OnPointerExit(eventData);
     m_OnExit.Invoke();
 }
示例#12
0
 // Update is called once per frame
 void Update()
 {
     if (pressed)
     {
         m_OnPressed.Invoke();
     }
 }
示例#13
0
 private void DoubleClick()
 {
     if (m_OnDoubleClick != null)
     {
         m_OnDoubleClick.Invoke();
     }
 }
示例#14
0
 void Update()
 {
     if (m_pointerPressed)
     {
         onHold?.Invoke();
     }
 }
示例#15
0
 public virtual void OnPointerClick(PointerEventData eventData)
 {
     if (m_pointerInside)
     {
         onClick.Invoke();
     }
 }
示例#16
0
 protected void InvokeClick(object sender, ButtonEventArgs args)
 {
     if (ButtonClickedEvent != null)
     {
         ButtonClickedEvent.Invoke(sender, args);
     }
 }
示例#17
0
 private void Press()
 {
     if (IsActive() && IsInteractable())
     {
         m_OnClick.Invoke();
     }
 }
示例#18
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (_ButtonClickedEvent != null)
     {
         _ButtonClickedEvent.Invoke(eventData);
     }
 }
示例#19
0
    /// <summary>
    /// Invokes the custom, user-defined event associated to the button press.
    /// </summary>
    /// <returns>The coroutine.</returns>
    private IEnumerator InvokeOnClickAction()
    {
        yield return(new WaitForSeconds(0.2f));

        blockInput = false;
        m_onClick.Invoke();
    }
示例#20
0
    public override void OnPointerClick(PointerEventData eventData)
    {
        base.OnPointerClick(eventData);

        if (!base.interactable)
        {
            return;
        }

        //if we are not using the left mouse button then break out
        if (eventData.button != PointerEventData.InputButton.Left)
        {
            return;
        }

        SfxHandler sfx = SfxHandler.SfxIns;

        if (sfx != null)
        {
            sfx.PlaySound("click_s");
        }

        //Invoke the event
        _onDown.Invoke();
    }
示例#21
0
 private void Press()
 {
     if (!IsActive() || !IsInteractable())
     {
         return;
     }
     m_OnClick.Invoke();
 }
示例#22
0
 public override void OnPointerDown(PointerEventData eventData)
 {
     base.OnPointerDown(eventData);
     CancelInvoke("LongPressTimer");
     Invoke("LongPressTimer", 1f);
     m_LongPressState = 1;
     m_OnPress.Invoke();
 }
示例#23
0
 private void LongClick()
 {
     if (!IsActive() || !isDown)
     {
         return;
     }
     m_OnLongClick.Invoke();
 }
示例#24
0
 public override void OnPointerDown(PointerEventData eventData)
 {
     base.OnPointerDown(eventData);
     if (interactable)
     {
         OnPressed?.Invoke();
     }
 }
示例#25
0
 private void Exit()
 {
     if (!IsActive() || !isEnter)
     {
         return;
     }
     m_OnExit.Invoke();
 }
示例#26
0
 private void Enter()
 {
     if (!IsActive())
     {
         return;
     }
     m_OnEnter.Invoke();
 }
示例#27
0
 private void Up()
 {
     if (!IsActive() || !IsInteractable() || !isDown)
     {
         return;
     }
     m_OnUp.Invoke();
 }
示例#28
0
 private void Press()
 {
     if (!IsActive() || !IsInteractable())
     {
         return;
     }
     UISystemProfilerApi.AddMarker("Button.onClick", this);
     m_OnClick.Invoke();
 }
示例#29
0
 private void Down()
 {
     if (!IsActive() || !IsInteractable())
     {
         return;
     }
     m_OnDown.Invoke();
     StartCoroutine(grow());
 }
示例#30
0
 private void Press()
 {
     if (!IsActive())
     {
         return;
     }
     m_animationClick?.Invoke();
     StartCoroutine(InvokeOnClickAction());
 }