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)); }
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); } }
/// <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)); }