Here are the examples of the csharp api UnityEngine.Vector2.Min(UnityEngine.Vector2, UnityEngine.Vector2) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
19
Source : BoundsUtils.cs
with GNU General Public License v3.0
from Keelhauled
with GNU General Public License v3.0
from Keelhauled
public static Rect BoundsToScreenRect(this Bounds bounds, Camera camera)
{
var cen = bounds.center;
var ext = bounds.extents;
var extentPoints = new Vector2[8]
{
camera.WorldToScreenPoint(new Vector3(cen.x-ext.x, cen.y-ext.y, cen.z-ext.z)),
camera.WorldToScreenPoint(new Vector3(cen.x+ext.x, cen.y-ext.y, cen.z-ext.z)),
camera.WorldToScreenPoint(new Vector3(cen.x-ext.x, cen.y-ext.y, cen.z+ext.z)),
camera.WorldToScreenPoint(new Vector3(cen.x+ext.x, cen.y-ext.y, cen.z+ext.z)),
camera.WorldToScreenPoint(new Vector3(cen.x-ext.x, cen.y+ext.y, cen.z-ext.z)),
camera.WorldToScreenPoint(new Vector3(cen.x+ext.x, cen.y+ext.y, cen.z-ext.z)),
camera.WorldToScreenPoint(new Vector3(cen.x-ext.x, cen.y+ext.y, cen.z+ext.z)),
camera.WorldToScreenPoint(new Vector3(cen.x+ext.x, cen.y+ext.y, cen.z+ext.z))
};
var min = extentPoints[0];
var max = extentPoints[0];
foreach(var v in extentPoints)
{
min = Vector2.Min(min, v);
max = Vector2.Max(max, v);
}
return new Rect(min.x, min.y, max.x-min.x, max.y-min.y);
}
19
Source : Geometry.cs
with MIT License
from microsoft
with MIT License
from microsoft
public static Rect GetRect(IList<Vector2> vertices)
{
Vector2 min = vertices[0];
Vector2 max = vertices[0];
for (var i = 1; i < vertices.Count; i++)
{
var vertex = vertices[i];
min = Vector2.Min(min, vertex);
max = Vector2.Max(max, vertex);
}
return Rect.MinMaxRect(min.x, min.y, max.x, max.y);
}
19
Source : TransformExtensions.cs
with MIT License
from peteschmitz
with MIT License
from peteschmitz
public static Rect AsGuiRect(this Bounds bounds)
{
Vector3 cen = bounds.center;
Vector3 ext = bounds.extents;
Vector2[] extentPoints = new Vector2[8]
{
WorldToGUIPoint(new Vector3(cen.x-ext.x, cen.y-ext.y, cen.z-ext.z)),
WorldToGUIPoint(new Vector3(cen.x+ext.x, cen.y-ext.y, cen.z-ext.z)),
WorldToGUIPoint(new Vector3(cen.x-ext.x, cen.y-ext.y, cen.z+ext.z)),
WorldToGUIPoint(new Vector3(cen.x+ext.x, cen.y-ext.y, cen.z+ext.z)),
WorldToGUIPoint(new Vector3(cen.x-ext.x, cen.y+ext.y, cen.z-ext.z)),
WorldToGUIPoint(new Vector3(cen.x+ext.x, cen.y+ext.y, cen.z-ext.z)),
WorldToGUIPoint(new Vector3(cen.x-ext.x, cen.y+ext.y, cen.z+ext.z)),
WorldToGUIPoint(new Vector3(cen.x+ext.x, cen.y+ext.y, cen.z+ext.z))
};
Vector2 min = extentPoints[0];
Vector2 max = extentPoints[0];
foreach (Vector2 v in extentPoints)
{
min = Vector2.Min(min, v);
max = Vector2.Max(max, v);
}
return new Rect(min.x, min.y, max.x - min.x, max.y - min.y);
}
19
Source : GroupController.cs
with MIT License
from XINCGer
with MIT License
from XINCGer
public void Select (Vector2 _start, Vector2 _end) {
_start.y = Screen.height - _start.y;
_end.y = Screen.height - _end.y;
Vector2 start = Vector2.Min(_start, _end);
Vector2 end = Vector2.Max(_start, _end);
if ((end-start).sqrMagnitude < 4*4) return;
selection.Clear();
RVOExampleAgent[] rvo = FindObjectsOfType(typeof(RVOExampleAgent)) as RVOExampleAgent[];
for (int i = 0; i < rvo.Length; i++) {
Vector2 sp = cam.WorldToScreenPoint(rvo[i].transform.position);
if (sp.x > start.x && sp.y > start.y && sp.x < end.x && sp.y < end.y) {
selection.Add(rvo[i]);
}
}
}