Guest User

MinimapMesh.cs

a guest
Jul 28th, 2025
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.AI;
  3.  
  4. public class MinimapMesh : MonoBehaviour
  5. {
  6.     [SerializeField]
  7.     MeshFilter filter;
  8.     void Awake()
  9.     {
  10.         Bake();
  11.     }
  12.  
  13.     [ContextMenu("Bake Mesh")]
  14.     void Bake()
  15.     {
  16.         // Getnavmesh data
  17.         NavMeshTriangulation triangles = NavMesh.CalculateTriangulation();
  18.         // Create new mesh with data
  19.         Mesh mesh = new Mesh();
  20.         mesh.vertices = triangles.vertices;
  21.         mesh.triangles = triangles.indices;
  22.         // set to mesh filter      
  23.         filter.mesh = mesh;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment