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

有时候我们做固定平面的3D游戏的时候,有3D镜头适配的需求,最近正好遇到了,临时编了一个,拿出来和大家一起分享:
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视觉适配

猜你喜欢

转载自blog.csdn.net/a3636987/article/details/45370195