Advertisement
Guest User

NavMeshBuildSource update helper class

a guest
Apr 10th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. public class NavMeshBuildSourcePositionUpdater : MonoBehaviour {
  2.     public NavMeshBuildSource mySource;
  3.     public Transform myTransform;
  4.     public Mesh myMesh;
  5.     public int index;
  6.  
  7.     public void UpdatePosition()
  8.     {
  9.         mySource.transform = myTransform.localToWorldMatrix;
  10.     }
  11.  
  12.     public NavMeshBuildSource CloneSource()
  13.     {
  14.         NavMeshBuildSource newSource = new NavMeshBuildSource();
  15.         newSource.area = mySource.area;
  16.         newSource.shape = mySource.shape;
  17.  
  18.         if(mySource.shape == NavMeshBuildSourceShape.Mesh)
  19.         {
  20.             newSource.sourceObject = myMesh;
  21.         } else {
  22.             newSource.size = mySource.size;
  23.         }
  24.  
  25.         newSource.transform = myTransform.localToWorldMatrix;
  26.         mySource = newSource;
  27.         return newSource;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement