Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. //The local min and maxes
  2. Vector2 min = new Vector2(newMeshFilter.mesh.bounds.min.x, newMeshFilter.mesh.bounds.min.z);
  3. Vector2 max = new Vector2(newMeshFilter.mesh.bounds.max.x, newMeshFilter.mesh.bounds.max.z);
  4. float spanX = Mathf.Abs(min.x - max.x);
  5. float spanZ = Mathf.Abs(min.y - max.y);
  6.  
  7. Vector3[] verticies = newMeshFilter.mesh.vertices;
  8.  
  9. for(int v = 0; v < verticies.Length; v++)
  10. {
  11. Vector2 position = new Vector2(verticies[v].x, verticies[v].z);
  12.  
  13. //~~~~Important Part:~~~~
  14. float newX = 1-((position.x/spanX));
  15. float newZ = 1-((position.y/spanZ));
  16. //print("newX: "+newX + ", newZ: "+newZ);
  17. verticies[v] = new Vector3(newX, verticies[v].y, newZ);
  18. }
  19.  
  20. newMeshFilter.mesh.vertices = verticies;
  21. newMeshFilter.mesh.RecalculateBounds();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement