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)); } } }
public override void OnPointerEnter(PointerEventData eventData) { base.OnPointerEnter(eventData); if (Panel.mouseButton) { onSelfClick?.Invoke(); } }
public virtual void OnPointerClick(PointerEventData eventData) { if (IsActive() && IsInteractable()) { if (eventData.button == PointerEventData.InputButton.Left) { m_OnClick.Invoke(); } } }
private void ButtonRelease() { if (!IsActive() || !IsInteractable()) { return; } UISystemProfilerApi.AddMarker("Button.onRelease", this); m_OnRelease.Invoke(); }
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; } }
public virtual void OnPointerUp(PointerEventData eventData) { if (eventData.button != PointerEventData.InputButton.Left) { return; } m_pointerPressed = false; Unpress(); if (m_pointerInside) { m_OnClick.Invoke(); } }
protected void LeftMouseUpEventHandler(object sender, MouseEventArgs args) { if (_mouseOver && ButtonClickedEvent != null) { ButtonClickedEvent.Invoke(this, new ButtonEventArgs(this)); } }
public void Draw() { if (GUI.Button(m_Rect, m_Label)) { m_OnClick.Invoke(); } }
public override void OnPointerUp(PointerEventData eventData) { base.OnPointerUp(eventData); CancelInvoke("LongPressTimer"); m_OnRelease.Invoke(); m_LongPressFrame = m_LongPressState > 1 ? Time.frameCount : 0; }
public override void OnPointerExit(PointerEventData eventData) { m_LongPressState = m_LongPressState == 2 ? 3 : -1; CancelInvoke("LongPressTimer"); base.OnPointerExit(eventData); m_OnExit.Invoke(); }
// Update is called once per frame void Update() { if (pressed) { m_OnPressed.Invoke(); } }
private void DoubleClick() { if (m_OnDoubleClick != null) { m_OnDoubleClick.Invoke(); } }
void Update() { if (m_pointerPressed) { onHold?.Invoke(); } }
public virtual void OnPointerClick(PointerEventData eventData) { if (m_pointerInside) { onClick.Invoke(); } }
protected void InvokeClick(object sender, ButtonEventArgs args) { if (ButtonClickedEvent != null) { ButtonClickedEvent.Invoke(sender, args); } }
private void Press() { if (IsActive() && IsInteractable()) { m_OnClick.Invoke(); } }
public void OnPointerClick(PointerEventData eventData) { if (_ButtonClickedEvent != null) { _ButtonClickedEvent.Invoke(eventData); } }
/// <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(); }
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(); }
private void Press() { if (!IsActive() || !IsInteractable()) { return; } m_OnClick.Invoke(); }
public override void OnPointerDown(PointerEventData eventData) { base.OnPointerDown(eventData); CancelInvoke("LongPressTimer"); Invoke("LongPressTimer", 1f); m_LongPressState = 1; m_OnPress.Invoke(); }
private void LongClick() { if (!IsActive() || !isDown) { return; } m_OnLongClick.Invoke(); }
public override void OnPointerDown(PointerEventData eventData) { base.OnPointerDown(eventData); if (interactable) { OnPressed?.Invoke(); } }
private void Exit() { if (!IsActive() || !isEnter) { return; } m_OnExit.Invoke(); }
private void Enter() { if (!IsActive()) { return; } m_OnEnter.Invoke(); }
private void Up() { if (!IsActive() || !IsInteractable() || !isDown) { return; } m_OnUp.Invoke(); }
private void Press() { if (!IsActive() || !IsInteractable()) { return; } UISystemProfilerApi.AddMarker("Button.onClick", this); m_OnClick.Invoke(); }
private void Down() { if (!IsActive() || !IsInteractable()) { return; } m_OnDown.Invoke(); StartCoroutine(grow()); }
private void Press() { if (!IsActive()) { return; } m_animationClick?.Invoke(); StartCoroutine(InvokeOnClickAction()); }