示例#1
0
    void onBackInputDown(BaseTouchSystem.Gesture _selection)
    {
        if (!_isDown)
        {
            _isDown  = true;
            _v2Down  = _selection.startPosition;
            _DragDis = 0;
        }
        else
        {
            if (instance._tapStartRaycastedItem != null)
            {
                return;
            }
            _v2Down  += CEventTouchDistrubtion.CurTouch.deltaPosition;
            _DragDis += Vector2.SqrMagnitude(CEventTouchDistrubtion.CurTouch.deltaPosition);

            if (_DragDis > thredhold)
            {
                Vector3 oldpos = instance.MainCamera.transform.position;
                instance.MainCamera.transform.position += new Vector3(-CEventTouchDistrubtion.CurTouch.deltaPosition.x / 100.0f,
                                                                      CEventTouchDistrubtion.CurTouch.deltaPosition.y / 100.0f,
                                                                      0);
                Vector3 pos = instance.MainCamera.transform.position;
                pos.x = Mathf.Clamp(pos.x, leftx, rightx);
                instance.MainCamera.transform.position = new Vector3(pos.x, 3.95f, instance.MainCamera.transform.position.z);
            }
        }
    }
示例#2
0
    private void On_TouchDown(BaseTouchSystem.Gesture gesture)
    {
        if (gesture.fingerIndex > 0)
        {
            return;
        }
        _curTouch = gesture;
        float      dis   = 1000000;
        float      depth = -1;
        GameObject go    = null;

        foreach (Camera cm in _activeCameras)
        {
            if (cm == null)
            {
                continue;
            }
            if (!cm.gameObject.activeSelf)
            {
                continue;
            }
            if (!cm.gameObject.activeInHierarchy)
            {
                continue;
            }
            if (!cm.enabled)
            {
                continue;
            }

            Ray        r = cm.ScreenPointToRay(gesture.position);
            RaycastHit hit;
            if (Physics.Raycast(r, out hit, 1000, cm.cullingMask))
            {
                if (cm.depth > depth && hit.distance < dis)
                {
                    go    = hit.collider.gameObject;
                    dis   = hit.distance;
                    depth = cm.depth;
                }
            }
        }
        if (CanHandleTouch(go))
        {
            _current = go;
            if (_touchDownListeners.ContainsKey(_current))
            {
                _touchDownListeners[_current].Invoke(_current);

                // Debug.LogError("_touchDownListeners " + _current.name);
            }
        }
    }
示例#3
0
    void onBackInputUp(BaseTouchSystem.Gesture _selection)
    {
        if (_isDown)
        {
            //  点击
            if (_DragDis < thredhold)
            {
            }
            else
            {
                //  拖动
            }

            _isDown = false;
        }
    }
示例#4
0
    private void On_TouchUp(BaseTouchSystem.Gesture gesture)
    {
        if (gesture.fingerIndex > 0)
        {
            return;
        }
        _curTouch = gesture;
        float      dis   = 1000000;
        float      depth = -1;
        GameObject go    = null;

        foreach (Camera cm in _activeCameras)
        {
            if (cm == null)
            {
                continue;
            }
            if (!cm.gameObject.activeSelf)
            {
                continue;
            }
            if (!cm.gameObject.activeInHierarchy)
            {
                continue;
            }
            if (!cm.enabled)
            {
                continue;
            }

            Ray        r = cm.ScreenPointToRay(gesture.position);
            RaycastHit hit;
            if (Physics.Raycast(r, out hit, dis, cm.cullingMask))
            {
                Debug.DrawRay(r.origin, Vector3.forward * hit.distance, Color.green, 5);
                if (cm.depth > depth && hit.distance < dis)
                {
                    go    = hit.collider.gameObject;
                    dis   = hit.distance;
                    depth = cm.depth;
                }
            }
            else
            {
                Debug.DrawRay(r.origin, Vector3.forward * 1000, Color.black, 5);
            }
        }

        if (EventSystem.current.currentSelectedGameObject != null)
        {
            Button _ClickButton = EventSystem.current.currentSelectedGameObject.GetComponent <Button>();
            if (_ClickButton != null)
            {
                // Debug.LogError("EventConfig.CLICK_BUTTON " + path);
            }
            else
            {
                Toggle _Tog = EventSystem.current.currentSelectedGameObject.GetComponent <Toggle>();
                if (_Tog != null)
                {
                }
            }
        }

        if (CanHandleTouch(go))
        {
            if (go == _current)
            {
                if (_clickListeners.ContainsKey(go) && _curTouch.actionTime < 0.2f)
                {
                    _clickListeners[go].Invoke(go);

                    // Debug.LogError("_clickListeners " + _current.name);
                }
            }
            if (_touchUpListeners.ContainsKey(go))
            {
                _touchUpListeners[go].Invoke(go);

                // Debug.LogError("_touchUpListeners " + _current.name);
            }
        }

        /*
         * {
         *  if (Ngame.ABSystem.AssetBundleManager.Instance.Inited)
         *  {
         *      CBEffectInstance eff = CBEffectPool.Instance.PlayEffect("Effect/Prefabe/uieffect_dianji", 1f);
         *      Vector3 pos = CBEffectPool.Instance.EffectCamera.ScreenToWorldPoint(new Vector3(_curTouch.position.x, _curTouch.position.y, 10));
         *      eff.Effect.transform.position = pos;
         *  }
         * }
         */
    }