public class LookAtCamera : MonoBehaviour
{
private enum Mode
{
LookAt,
LookAtInverted,
Forward,
ForwardInverted,
}
[SerializeField] private Mode mode;
void LateUpdate()
{
switch (mode)
{
case Mode.LookAt:
transform.LookAt(Camera.main.transform);
break;
case Mode.LookAtInverted:
Vector3 dirFromCamera = transform.position - Camera.main.transform.forward;
transform.LookAt(dirFromCamera);
break;
case Mode.Forward:
transform.forward = Camera.main.transform.forward;
break;
case Mode.ForwardInverted:
transform.forward = -Camera.main.transform.forward;
break;
}
}
}
标签:case,朝向,transform,相机,Camera,UI,Mode,forward,LookAt
From: https://www.cnblogs.com/dewxin/p/17284103.html