// Update is called once per frame void Update() { //Debug.Log(Input.mousePosition.y); if (currentPiece == null) { //canvas.GetComponent<tiletimerHandler>().timerReset(); GeneratePiece(); LongPress lp = currentPiece.AddComponent <LongPress>() as LongPress; // Debug.Log("Piece generated"); } /* * else { * if (pointerDown ) * { * * game_field = GameObject.FindGameObjectWithTag("game_field"); * //Debug.Log("got mouse click"); * //Debug.Log(currentPiece.name); * rotatePiece(); * } * //Debug.Log("Nada generated"); * } */ }
void ShowTips(SkillDatabase db, Transform item, Vector2 offset) { LongPress lp = item.GetComponent <LongPress>(); if (lp == null) { lp = item.gameObject.AddComponent <LongPress>(); } lp.InitLongPress(() => { DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.PlayerSkillTipsPanel, panelShowAction: (pb) => { if (null != pb && pb is PlayerSkillTipsPanel) { PlayerSkillTipsPanel panel = pb as PlayerSkillTipsPanel; if (panel != null) { panel.InitParentTransform(item, offset); panel.ShowUI(PlayerSkillTipsPanel.SkillTipsType.Pet, db); } } }); }, () => { DataManager.Manager <UIPanelManager>().HidePanel(PanelID.PlayerSkillTipsPanel); }); }
public void ExitPress(LongPress longPress) { if (longPress.enabled == true) { longPress.enabled = false; } }
//短按点击 public void AddButtonOnClickListener(UnityAction action) { LongPress tmpLong = transform.GetComponent <LongPress>(); if (tmpLong != null) { tmpLong.onClick.AddListener(action); } }
private IEnumerator Hold() { yield return(new WaitForSeconds(Delay)); if (isHold) { LongPress?.Invoke(); } }
private IEnumerator ContinuousHold() { yield return(new WaitForSeconds(Delay)); while (isHold) { yield return(null); LongPress?.Invoke(); } }
private async void OnPreviewPress(object sender, RoutedEventArgs e) { if (!IsEnabled) { return; } if (firstMouseDownHash == -1) { firstMouseDownHash = GetHashCode(); IsPressedInternal = true; if (e is MouseButtonEventArgs) { PreviewMouseLeftButtonDown?.Invoke(sender, e as MouseButtonEventArgs); } else if (e is TouchEventArgs) { PreviewTouchDown?.Invoke(sender, e as TouchEventArgs); } PressHold?.Invoke(this, new PressHoldEventArgs(PressHoldEventArgs.EventType.Press)); if (LongPressEnabled) { var longPressMSec = LongPressDelay.TotalMilliseconds; var longPressStep = 10; var longPressStepDelay = longPressMSec / longPressStep; while (longPressMSec > 0) { if (firstMouseDownHash == -1) { break; } await Task.Delay(TimeSpan.FromMilliseconds(longPressStepDelay)); longPressMSec -= longPressStepDelay; } if (firstMouseDownHash == GetHashCode()) { ReleaseAllTouchCaptures(); ReleaseMouseCapture(); firstMouseDownHash = -1; LongPress?.Invoke(this, e); IsPressedInternal = false; e.Handled = true; } } } }
void InitLongPress(Transform item) { LongPress lp = item.gameObject.GetComponent <LongPress>(); if (lp == null) { lp = item.gameObject.AddComponent <LongPress>(); } lp.InitLongPress(() => { OnCommonAttack(item.gameObject); }, () => { }, doubleSkillTime); }
/// <summary> /// 给控件添加长按脚本以满足特殊需求 /// </summary> /// <param name="root"></param> private void AddLongPress(Transform root) { for (int i = 0; i < root.childCount; i++) { Transform tmpChild = root.GetChild(i); LongPress tmpBehav = tmpChild.GetComponent <LongPress>(); if (tmpBehav != null) { continue; } if (!transform.name.EndsWith("_n")) { tmpChild.gameObject.AddComponent <LongPress>(); if (transform.name.EndsWith("_m")) { continue; } } if (tmpChild.childCount > 0) { AddBehaviours(tmpChild); } } }
/// <summary> /// Raises the <see cref="LongPress"/> event. /// </summary> /// <param name="touchID">The unique identifier of the touch input.</param> /// <param name="fingerID">The unique identifier of the finger which caused the touch.</param> /// <param name="x">The normalized x-coordinate of the touch.</param> /// <param name="y">The normalized y-coordinate of the touch.</param> /// <param name="pressure">The normalized pressure of the touch.</param> protected virtual void OnLongPress(Int64 touchID, Int64 fingerID, Single x, Single y, Single pressure) { LongPress?.Invoke(this, touchID, fingerID, x, y, pressure); }
public void HandleLongPress(object sender, EventArgs e) { LongPress?.Invoke(this, new EventArgs()); }
/// <summary> /// 设置长按 /// </summary> /// <param name="bSet">true是设置 false是清空</param> void SetLongPressEvent(bool bSet) { //暂时去除长按tips功能 return; LongPress lp = this.gameObject.GetComponent <LongPress>(); if (lp == null) { lp = this.gameObject.AddComponent <LongPress>(); } if (bSet) { lp.InitLongPress(() => { DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.PlayerSkillTipsPanel, panelShowAction: (pb) => { if (null != pb && pb is PlayerSkillTipsPanel) { PlayerSkillTipsPanel panel = pb as PlayerSkillTipsPanel; Client.IPlayer mainPlayer = ClientGlobal.Instance().MainPlayer; if (mainPlayer == null) { return; } panel.InitParentTransform(transform, new Vector2(m_nSprwidth, m_nSprheight)); //bool bRide = DataManager.Manager<RideManager>().IsRide; //if (!bRide) { table.SkillDatabase db = GameTableManager.Instance.GetTableItem <table.SkillDatabase>((uint)m_skillid, 1); if (db != null) { if (m_skillBtnIndex == 9)//宠物技能 { panel.ShowUI(PlayerSkillTipsPanel.SkillTipsType.Pet, db); } else { panel.ShowUI(PlayerSkillTipsPanel.SkillTipsType.Player, db); } } } //else //{ // table.RideSkillDes rideSkill = GameTableManager.Instance.GetTableItem<table.RideSkillDes>((uint)m_skillid); // if (rideSkill != null) // { // panel.ShowUI(PlayerSkillTipsPanel.SkillTipsType.Ride, rideSkill); // } //} } }); }, () => { DataManager.Manager <UIPanelManager>().HidePanel(PanelID.PlayerSkillTipsPanel); }, 500); } else { lp.InitLongPress(null, null); } }
public virtual void OnLongPress() { onLongPress?.Invoke(); LongPress?.Invoke(this, EventArgs.Empty); }
public void OnLongPress(object v) { LongPress?.Invoke(this, new SelectedItemChangedEventArgs(v)); LongPressCommand?.Execute(v); }
//按下 public void StartPress(LongPress longPress) { pressTr = longPress.transform; longPress.enabled = true; }
public void OnLongPress(JuniperPointerEventData evt) { onLongPress?.Invoke(evt); LongPress?.Invoke(this, evt); }
protected virtual void OnLongPress() { LongPress?.Invoke(this, EventArgs.Empty); }