程序员人生 网站导航

3D相机在固定场景中的适配(Unity之3D相机适配)

栏目:综合技术时间:2015-05-05 08:17:42
有时候我们做固定平面的3D游戏的时候,有3D镜头适配的需求,最近正好遇到了,临时编了1个,拿出来和大家1起分享:
using UnityEngine; using System.Collections; public class ScreenUnit : MonoBehaviour { private float height = 480; private float width = 854; private float rate1 = 480 / 854.0f; private float rate2; // Use this for initialization void Start () { rate2 = Screen.height / (float)Screen.width; gameObject.GetComponent<Camera>().fieldOfView *= 1 + (rate2 - rate1); } }
将脚本托给相机,就能够实现简单的多机型3D视觉适配
------分隔线----------------------------
------分隔线----------------------------

最新技术推荐