Guest User

MiniMapCamController.cs

a guest
Jul 1st, 2025
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class MiniMapCamController : MonoBehaviour
  4. {
  5.     [SerializeField]
  6.     Camera m_cam;
  7.  
  8.     public void SetMapPosToThis(MeshFilter meshFilter)
  9.     {
  10.         SetMesh(meshFilter);
  11.         // offset to the top of the mesh, with an extra up
  12.         Vector3 center = meshFilter.transform.position + meshFilter.sharedMesh.bounds.center + Vector3.up;
  13.         center.y += meshFilter.sharedMesh.bounds.extents.y;
  14.         transform.position = center;
  15.     }
  16.  
  17.     public void SetMesh(MeshFilter meshFilter)
  18.     {
  19.         // set ortho size to be the mesh size with a little buffer
  20.         float size = meshFilter.sharedMesh.bounds.size.magnitude * 0.55f;
  21.         m_cam.orthographicSize = size;
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment