Engine/Unity

유니티 Billboard Renderer 직접 구현할 필요가 없다

VirtualDever 2023. 2. 11. 21:15

지금까지는 아래 코드와 같이 billboard를 직접 구현해서 썻는데 검색해 보니까 billboard renderer 라는 컴포넌트가 있더라!

 

public class CameraFacingBillboard : MonoBehaviour {
    private Camera m_Camera;
    private Transform m_Transform;

    private void Awake() {
      m_Camera = Camera.main;
      m_Transform = transform;
    }

    void Update() {
      m_Transform.LookAt(transform.position + m_Camera.transform.rotation * Vector3.forward,
        m_Camera.transform.rotation * Vector3.up);
    }
  }

 

이제는 게임 오브젝트에 billboard renderer를 달아주고 옵션 설정만 하면 되는구나!

참고 문서

https://docs.unity3d.com/2021.3/Documentation/Manual/class-BillboardRenderer.html

 

Unity - Manual: Billboard Renderer component

Billboard Renderer component Switch to Scripting The Billboard Renderer renders Billboard Assets. Billboards are a level-of-detail (LOD) method for drawing complicated 3D Meshes in a simpler way when they are far away from the CameraA component which creat

docs.unity3d.com