赞
踩
3dUI始终面向摄像机,广告牌效果
public class SimpleBillboard : MonoBehaviour { public bool IsStopInSceneView = false; void OnDrawGizmos() { if (IsStopInSceneView == false && Application.isPlaying == false && SceneView.currentDrawingSceneView.camera != null) { Rot(SceneView.currentDrawingSceneView.camera. transform); } } void Update() { Rot(Camera.main.camera.transform); } void Rot(Transform target) { Plane plane = new Plane(target.forward, target.position); float dis; Vector3 tar = target.position; if (plane.Raycast(new Ray(this.transform.position, -target.forward),out dis) == true) { tar = this.transform.position + (-target.forward * dis); } this.transform.LookAt(tar, Vector3.up); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。