Ejemplo n.º 1
0
 private PointerDeviceType GetPointerDeviceType(UITouchType touchType) =>
 touchType switch
 {
Ejemplo n.º 2
0
		public static NSNumber [] TouchTypes (UITouchType type)
		{
			return new NSNumber [] { new NSNumber ((long)type) };
		}
Ejemplo n.º 3
0
 public static NSNumber [] TouchTypes(UITouchType type)
 {
     return(new NSNumber [] { new NSNumber((long)type) });
 }
Ejemplo n.º 4
0
    /// <summary>
    /// 刷新数据
    /// </summary>
    void Update()
    {
        /// 数据初始化
        for (int index = 0; index < _listTouch.Count; index++)
        {
            _listTouch[index].IsCanceled = true;
        }

#if UNITY_EDITOR
        if (Input.GetMouseButtonDown(0))
        {
            if (null == EventSystem.current || !EventSystem.current.IsPointerOverGameObject())
            {
                if (!_hashTouch.ContainsKey(0))
                {
                    _hashTouch.Add(0, new TouchData());
                    _listTouch.Add(_hashTouch[0]);
                }
            }
        }
        if (Input.GetMouseButtonUp(0))
        {
            if (_hashTouch.ContainsKey(0))
            {
                _listTouch.Remove(_hashTouch[0]);
                _hashTouch.Remove(0);
            }
        }
        for (int index = 0; index < _listTouch.Count; index++)
        {
            _listTouch[index].IsCanceled = false;
        }
#endif

        /// 检测所有Touch点
        for (int index = 0; null != Input.touches && index < Input.touches.Length; index++)
        {
            ///Debug.LogFormat("nput.touches[{0}].phase = {1}", index, Input.touches[index].phase);
            /// 新增 Touch 点
            if (Input.touches[index].phase == TouchPhase.Began)
            {
                /// 排除UI层
                if (null == EventSystem.current || !EventSystem.current.IsPointerOverGameObject(Input.touches[index].fingerId))
                {
                    if (!_hashTouch.ContainsKey(Input.touches[index].fingerId))
                    {
                        _hashTouch.Add(Input.touches[index].fingerId, new TouchData(Input.touches[index]));
                        _listTouch.Add(_hashTouch[Input.touches[index].fingerId]);
                        continue;
                    }
                }
            }
            /// 移除 Touch 点
            if (Input.touches[index].phase == TouchPhase.Canceled)
            {
                if (_hashTouch.ContainsKey(Input.touches[index].fingerId))
                {
                    _listTouch.Remove(_hashTouch[Input.touches[index].fingerId]);
                    _hashTouch.Remove(Input.touches[index].fingerId);
                    continue;
                }
            }
            /// 自证 Touch 点没移除
            if (_hashTouch.ContainsKey(Input.touches[index].fingerId))
            {
                _hashTouch[Input.touches[index].fingerId].IsCanceled = false;
                _hashTouch[Input.touches[index].fingerId].touch      = Input.touches[index];
            }
        }

        /// 对 Touch 点进行清理操作
        for (int index = _listTouch.Count - 1; index >= 0; index--)
        {
            if (_listTouch[index].IsCanceled)
            {
                _hashTouch.Remove(_listTouch[index].fingerId);
                _listTouch.RemoveAt(index);
            }
        }
        /// 对状态 进行清理操作
        switch (_type)
        {
        case UITouchType.None:
            /// 原始状态转换
            if (_listTouch.Count > 0)
            {
                _type = (UITouchType)Mathf.Min(_listTouch.Count, 3);
            }
            break;

        case UITouchType.Touch_1:
            /// 一根手指时候可以不考虑逻辑
            /// 随意切换
            _type = (UITouchType)Mathf.Min(_listTouch.Count, 3);
            break;

        case UITouchType.Touch_2:
        case UITouchType.Touch_3:
            /// 三个或者两个手指 直接切换为空状态
            if (_listTouch.Count <= 1)
            {
                _type = UITouchType.None;
            }
            break;
        }
    }