示例#1
0
        private Vector3 UF_GetPressPosition()
        {
            Vector3 pos = UIManager.UICamera.ScreenToWorldPoint(DeviceInput.UF_PressPosition(0));

            pos.z = this.transform.position.z;
            return(pos);
        }
示例#2
0
        private void UpdateInput()
        {
            if (maskGraphicTrigger && DeviceInput.UF_Press(0))
            {
                if (uiCamera == null)
                {
                    return;
                }
                //停止复位
                m_IsResumePoint = false;

                if (!m_IsPress)
                {
                    m_SourceDragPos = DeviceInput.UF_DownPosition(0);
                    joyRoot.gameObject.transform.position = uiCamera.ScreenToWorldPoint(m_SourceDragPos);
                    m_IsPress = true;
                    UF_CallDelegateEvent(m_EventJoyPressDown);
                    UF_CallUnityEvent(m_UEventPressDown);
                }
                if (m_IsPress)
                {
                    m_TargetDragPos = DeviceInput.UF_PressPosition(0);
                    float dist   = Vector3.Distance(m_SourceDragPos, m_TargetDragPos);
                    float limitV = limtPointDistance * Screen.width / UIManager.FixedWidth;

                    if (dist > limitV)
                    {
                        m_TargetDragPos = m_SourceDragPos + (m_TargetDragPos - m_SourceDragPos).normalized * limitV;
                    }
                    if (joyPoint != null)
                    {
                        joyPoint.gameObject.transform.position = uiCamera.ScreenToWorldPoint(m_TargetDragPos);
                    }
//					float angle = 0;
                    Vector3 _moveVector = MathX.UF_Foward(m_SourceDragPos, m_TargetDragPos);
                    if (dist > deadZoom)
                    {
                        m_MoveForward = new Vector3(_moveVector.x, gravity, _moveVector.y).normalized;
                        UF_CallDelegateEvent(m_EventJoyPressMove);
                        UF_UpdateRotate(m_MoveForward);
                    }
                }
            }
            else
            {
                if (m_IsPress)
                {
                    m_IsPress = false;
                    UF_ResumePoint(); UF_UpdateRevertRoot();
                    UF_CallDelegateEvent(m_EventJoyPressUp);
                    UF_CallUnityEvent(m_UEventPressUp);
                }
            }
        }
示例#3
0
        void Update()
        {
            if (!m_BeginDraw)
            {
                return;
            }

            UF_updatePenPressure();

            Vector3 clickPoint = DeviceInput.UF_PressPosition(0);
            Vector2 pos;

            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rectTransform, clickPoint, canvas.worldCamera, out pos))
            {
                m_CurPoint = pos;
                if (m_NewBegin)
                {
                    m_LastPoint = m_CurPoint;
                    m_NewBegin  = false;
                }
                if (m_CurPoint != m_LastPoint)
                {
                    UF_DrawCircle((int)pos.x, (int)pos.y, m_CurPenSize, penColor, false);
                    //点插值补偿
                    float distance = Vector2.Distance(m_CurPoint, m_LastPoint);
                    float hfPSize  = m_CurPenSize / 2;
                    if (((int)distance) > hfPSize)
                    {
                        int     count   = (int)(distance / hfPSize + 1);
                        Vector2 current = Vector2.zero;
                        float   p       = 0;
                        for (int k = 0; k < count; k++)
                        {
                            p         = (float)k / (float)count;
                            current.x = m_LastPoint.x * p + m_CurPoint.x * (1 - p);
                            current.y = m_LastPoint.y * p + m_CurPoint.y * (1 - p);

                            UF_DrawCircle((int)current.x, (int)current.y, m_CurPenSize, penColor, false);
                        }
                    }
                    this.UF_Apply();
                    m_LastPoint = m_CurPoint;
                }
            }
        }
示例#4
0
        // Update is called once per frame
        public void UF_OnUpdate()
        {
            if (!IsActive)
            {
                return;
            }
            if (m_IsPress && UsePress)
            {
                m_CurrentPressTime += GTime.RunDeltaTime;
                if (m_CurrentPressTime >= PressInterval)
                {
                    m_CurrentPressTime = 0;
                    RaycastHit hit;
                    Camera     camera = Camera.main;
                    if (camera != null && !IsUIRayCast() && Physics.Raycast(camera.ScreenPointToRay(DeviceInput.UF_PressPosition(0)), out hit, Distance))
                    {
                        MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_LUA, DefineLuaEvent.E_RAYCAST_HIT, hit);
                    }
                }
                if (!DeviceInput.UF_Press(0))
                {
                    m_CurrentPressTime = 0;
                }
            }
            else
            {
                if (DeviceInput.UF_Down(0))
                {
                    RaycastHit hit;
                    Camera     camera = Camera.main;
                    if (camera != null && !IsUIRayCast() && Physics.Raycast(camera.ScreenPointToRay(DeviceInput.UF_PressPosition(0)), out hit, Distance))
                    {
                        if (UsePress)
                        {
                            m_IsPress          = true;
                            m_CurrentPressTime = 0;
                        }
                        MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_LUA, DefineLuaEvent.E_RAYCAST_HIT, hit);
                    }
                }
            }

            if (!DeviceInput.UF_Press())
            {
                m_IsPress = false;
            }
        }