Пример #1
0
        static bool ScreenToPanel(PanelRenderer panelRenderer, ref Event evt, Vector2 screenPosition, Vector2 lastScreenPosition)
        {
            var panelPosition = Vector2.zero;
            var panelDelta    = Vector2.zero;

            if (!ScreenToPanel(panelRenderer, screenPosition, screenPosition - lastScreenPosition,
                               out panelPosition, out panelDelta))
            {
                return(false);
            }
            evt.mousePosition = panelPosition;
            evt.delta         = panelDelta;
            return(true);
        }
Пример #2
0
        static bool ScreenToPanel(PanelRenderer panelRenderer, ref Touch touch)
        {
            var panelPosition = Vector2.zero;
            var panelDelta    = Vector2.zero;

            if (!ScreenToPanel(panelRenderer, touch.position, touch.deltaPosition,
                               out panelPosition, out panelDelta))
            {
                return(false);
            }
            touch.position      = panelPosition;
            touch.deltaPosition = panelDelta;
            return(true);
        }
Пример #3
0
        static bool ScreenToPanel(PanelRenderer panelRenderer, Vector2 screenPosition, Vector2 screenDelta,
                                  out Vector2 panelPosition, out Vector2 panelDelta)
        {
            panelPosition = Vector2.zero;
            panelDelta    = Vector2.zero;

            if (!panelRenderer.ScreenToPanel(screenPosition, out panelPosition))
            {
                return(false);
            }
            var panelPrevPosition = Vector2.zero;

            if (panelRenderer.ScreenToPanel(screenPosition - screenDelta, out panelPrevPosition))
            {
                panelDelta = panelPosition - panelPrevPosition;
            }
            return(true);
        }