Esempio n. 1
0
 public static ButtonVisualStates GetButtonVisualState(UIInputManager im, object obj, UITouchInteraction ti = null)
 {
     if (ti != null && ti.PressedByTouchId != -1)
         return ButtonVisualStates.PRESSED;
     else if (im.m_mouseInteraction.ObjectPressed == obj)
         return ButtonVisualStates.PRESSED;
     else if (im.m_mouseInteraction.ObjectOver == obj)
         return ButtonVisualStates.MOUSEOVER;
     else
         return ButtonVisualStates.NORMAL;
 }
Esempio n. 2
0
        public static bool Button(UIInputManager im, object obj, float x0, float y0, float x1, float y1, UITouchInteraction ti)
        {
            if (!im.m_state.MouseDown)
            {
                if (im.MouseHitTest(x0, y0, x1, y1))
                    im.m_mouseInteraction.ObjectOver = obj;
                else if (im.m_mouseInteraction.ObjectOver == obj)
                    im.m_mouseInteraction.ObjectOver = null;
            }

            if (im.m_mouseInteraction.ObjectOver == obj)
            {
                if (im.m_state.MouseDown)
                    im.m_mouseInteraction.ObjectPressed = obj;
            }

            if (im.m_mouseInteraction.ObjectPressed == obj)
            {
                im.m_mouseInteraction.ObjectOver = im.MouseHitTest(x0, y0, x1, y1) ? obj : null;
                if (!im.m_state.MouseDown)
                {
                    im.m_mouseInteraction.ObjectPressed = null;

                    if (im.m_mouseInteraction.ObjectOver == obj)
                    {
                        // Triggering press, so dont do it doubly.
                        ti.PressedByTouchId = -1;
                        return true;
                    }
                }
            }

            if (ti != null)
            {
                bool pr = (ti.PressedByTouchId != -1) && ti.StillInside;
                im.TouchHitTest(x0, y0, x1, y1, ref ti);
                if (ti.PressedByTouchId == -1 && pr)
                {
                    //reset if needed
                    if (im.m_mouseInteraction.ObjectPressed == obj)
                        im.m_mouseInteraction.ObjectPressed = null;
                    return true;
                }
            }

            return false;
        }
Esempio n. 3
0
        public void TouchHitTest(float x0, float y0, float x1, float y1, ref UITouchInteraction interaction)
        {
            if (m_block == 0)
            {
                foreach (UITusch.Tch t in m_state.Touches)
                {
                    // if the touch we track appear again, reset everything...
                    if (t.phase == UnityEngine.TouchPhase.Began && interaction.PressedByTouchId == t.fingerId)
                        interaction.PressedByTouchId = -1;

                    if (t.position.x >= x0 && t.position.y >= y0 && t.position.x < x1 && t.position.y < y1)
                    {
                        if (t.phase == UnityEngine.TouchPhase.Began)
                        {
                            if (interaction.PressedByTouchId == -1)
                            {
                                interaction.PressedLocation = t.position;
                                interaction.PressedByTouchId = t.fingerId;
                            }
                        }

                        if (interaction.PressedByTouchId == t.fingerId)
                        {
                            interaction.CurrentLocation = t.position;
                            interaction.StillInside = true;
                        }
                        return;
                    }
                    else if (t.fingerId == interaction.PressedByTouchId)
                    {
                        interaction.CurrentLocation = t.position;
                        interaction.StillInside = false;
                        return;
                    }
                }
            }

            interaction.PressedByTouchId = -1;
            interaction.StillInside = false;
        }