Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //The local min and maxes
- Vector2 min = new Vector2(newMeshFilter.mesh.bounds.min.x, newMeshFilter.mesh.bounds.min.z);
- Vector2 max = new Vector2(newMeshFilter.mesh.bounds.max.x, newMeshFilter.mesh.bounds.max.z);
- float spanX = Mathf.Abs(min.x - max.x);
- float spanZ = Mathf.Abs(min.y - max.y);
- Vector3[] verticies = newMeshFilter.mesh.vertices;
- for(int v = 0; v < verticies.Length; v++)
- {
- Vector2 position = new Vector2(verticies[v].x, verticies[v].z);
- //~~~~Important Part:~~~~
- float newX = 1-((position.x/spanX));
- float newZ = 1-((position.y/spanZ));
- //print("newX: "+newX + ", newZ: "+newZ);
- verticies[v] = new Vector3(newX, verticies[v].y, newZ);
- }
- newMeshFilter.mesh.vertices = verticies;
- newMeshFilter.mesh.RecalculateBounds();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement