I am scaling my world space UI element as my camera go far away from UI using this code snippet:
public class ZoomNamePlace : MonoBehaviour
{
//public CameraController camContrller;
public int Zoom_Factor;
void LateUpdate()
{
Zoom();
}
void Zoom()
{
float size = (Camera.main.transform.position - transform.position).magnitude;
}
}
It is working fine and my UI scale according to the distance of Camera and UI. Now i want to rotate/billboard my world space UI to the camera and here is my script:
public class Billboard : MonoBehaviour
{
//Orient the camera after all movement is completed this frame to avoid jittering
void LateUpdate()
{
Camera m_Camera = Camera.main;
transform.LookAt(transform.position + m_Camera.transform.rotation * Vector3.forward,
m_Camera.transform.rotation * Vector3.up);
}
}
But the problem is instead of billboard my UI shape stretched too much maybe due to my canvas scale set to 0.01.