Guest User

MinimapMesh.cs

a guest
May 20th, 2020
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.AI;
  4.  
  5. [ExecuteInEditMode]
  6. public class MinimapMesh : MonoBehaviour
  7. {
  8.     void Awake()
  9.     {
  10.         MeshFilter filter = GetComponent<MeshFilter>();
  11.         // Getnavmesh data
  12.         NavMeshTriangulation triangles = NavMesh.CalculateTriangulation();
  13.  
  14.         // Create new mesh with data
  15.         Mesh mesh = new Mesh();
  16.         mesh.vertices = triangles.vertices;
  17.         mesh.triangles = triangles.indices;
  18.  
  19.  
  20.         // set to mesh filter      
  21.         filter.mesh = mesh;
  22.     }
  23. }
RAW Paste Data