您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
30 行
608 B
30 行
608 B
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
[ExecuteAlways]
|
|
public class CameraFacingBillboard : MonoBehaviour
|
|
{
|
|
public Camera camera;
|
|
|
|
void OnEnable()
|
|
{
|
|
camera = GameObject.Find("Main Camera").GetComponent<Camera>();
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
camera = null;
|
|
}
|
|
|
|
//Orient the camera after all movement is completed this frame to avoid jittering
|
|
void LateUpdate()
|
|
{
|
|
|
|
if(camera)
|
|
{
|
|
transform.LookAt(transform.position + camera.transform.rotation * Vector3.forward, camera.transform.rotation * Vector3.up);
|
|
}
|
|
|
|
|
|
}
|
|
}
|