Esempio n. 1
0
        public static Rect RectForPts(Vec2 a, Vec2 b)
        {
            Vec2 lower = Vec2.Min(a, b);
            Vec2 upper = Vec2.Max(a, b);

            return(new Rect(lower, upper - lower));
        }
Esempio n. 2
0
        void IDragHandler.OnDrag([NotNull] PointerEventData eventData)
        {
            if (targetTransform == null)
            {
                return;
            }

            float scale = 1f / ModuleListPanel.CanvasScale;
            var   size  = targetTransform.sizeDelta + Vector2.Scale(eventData.delta, new Vector2(scale, -scale));

            targetTransform.sizeDelta = Vector2.Max(size, minSize);
            ScaleChanged?.Invoke();
            //Debug.Log(targetTransform.sizeDelta);
        }
Esempio n. 3
0
        public void OnScroll(Vec2 delta)
        {
            float scroll = delta.y;

            cam.orthographicSize -= zoomZpeed * scroll;
            cam.orthographicSize  = Mathf.Clamp(cam.orthographicSize, minZoom, maxZoom);

            if (lockToMap)
            {
                Vec2 halfSize = new Vec2(cam.orthographicSize * cam.aspect, cam.orthographicSize);

                Vec2 pos = cam.transform.localPosition.xy();
                pos = Vec2.Max(pos, halfSize);
                pos = Vec2.Min(pos, game.size - halfSize);
                cam.transform.localPosition = new Vec3(pos.x, pos.y, -11);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Grows the Bounds to include the point.
 /// </summary>
 /// <param name="point"></param>
 public void Encapsulate(Vector2 point)
 {
     SetMinMax(Vector2.Min(min, point), Vector2.Max(max, point));
 }