static void FitUVs(Vector2[] uvs, IList <int> indexes) { var bounds = new Bounds2D(); bounds.SetWithPoints(uvs, indexes); var c = bounds.center; var s = Mathf.Max(bounds.size.x, bounds.size.y); for (int i = 0; i < indexes.Count; i++) { var uv = uvs[indexes[i]]; uv.x = ((uv.x - c.x) / s) + c.x; uv.y = ((uv.y - c.y) / s) + c.y; uvs[indexes[i]] = uv; } }
static void StretchUVs(Vector2[] uvs, IList <int> indexes) { var bounds = new Bounds2D(); bounds.SetWithPoints(uvs, indexes); var c = bounds.center; var s = bounds.size; for (int i = 0; i < indexes.Count; i++) { var uv = uvs[indexes[i]]; uv.x = ((uv.x - c.x) / s.x) + c.x; uv.y = ((uv.y - c.y) / s.y) + c.y; uvs[indexes[i]] = uv; } }