Beispiel #1
0
	/// <summary>
	/// クリック成立時
	/// </summary>
	public void OnPointerClick(PointerEventData eventData)
	{
		//クリック成立した指番号をリストから除去
		if (this.pointerIdList.Remove(eventData.pointerId))
		{
			//最後の指の時だけクリック成立
			if (this.pointerIdList.Count == 0)
			{
				//長押し判定の中断
				StopAllCoroutines();

				//クリック成立(1フレームだけ通知)
				this.state |= State.Click;
				this.state &= ~State.Pressing;
				StartCoroutine(CoroutineUtility.WaitForEndOfFrameAction(() =>
				{
					this.state = State.None;
				}));

				//イベント実行
				if (this.onClick != null)
				{
					this.onClick.Invoke();
				}
				if (!this.isLong)
				{
					if (this.onShortClick != null)
					{
						this.onShortClick.Invoke();
					}
				}
				else
				{
					if (this.onLongClick != null)
					{
						this.onLongClick.Invoke();
					}
				}
			}
		}
	}
Beispiel #2
0
	/// <summary>
	/// ボタンの範囲外に出た時
	/// </summary>
	public void OnPointerExit(PointerEventData eventData)
	{
		//何も管理していないのでreturn
		if (this.pointerIdList.Count == 0) return;

		//マウスの場合-1しか来ない
		if (eventData.pointerId == -1)
		{
			//管理している指番号を全部除去
			this.pointerIdList.Clear();
		}
		//マウス以外の場合
		else
		{
			//範囲外に出た指番号をリストから除去
			this.pointerIdList.Remove(eventData.pointerId);
		}

		//全ての指がボタンの範囲外に出た
		if (this.pointerIdList.Count == 0)
		{
			//長押し判定の中断
			StopAllCoroutines();

			//キャンセル発生(1フレームだけ通知)
			this.state = State.Cancel;
			StartCoroutine(CoroutineUtility.WaitForEndOfFrameAction(() =>
			{
				this.state = State.None;
			}));

			//イベント実行
			if (this.onCancel != null)
			{
				this.onCancel.Invoke();
			}
		}
	}