Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class MiniMapCamController : MonoBehaviour
- {
- [SerializeField]
- Camera m_cam;
- public void SetMapPosToThis(MeshFilter meshFilter)
- {
- SetMesh(meshFilter);
- // offset to the top of the mesh, with an extra up
- Vector3 center = meshFilter.transform.position + meshFilter.sharedMesh.bounds.center + Vector3.up;
- center.y += meshFilter.sharedMesh.bounds.extents.y;
- transform.position = center;
- }
- public void SetMesh(MeshFilter meshFilter)
- {
- // set ortho size to be the mesh size with a little buffer
- float size = meshFilter.sharedMesh.bounds.size.magnitude * 0.55f;
- m_cam.orthographicSize = size;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment