Portal belajar membuat aplikasi Augmented Reality dan Virtual Reality

Kamis, 12 April 2018

Plane Fill a Field Of View (Camera)

23.47 Posted by Dicky Rachmat Iskandar No comments
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FillScreen : MonoBehaviour {
     public Camera cam;
        void Update()
        {
            float pos = (cam.nearClipPlane + 0.01f);

            transform.position = cam.transform.position + cam.transform.forward * pos;

            float h = Mathf.Tan(cam.fieldOfView * Mathf.Deg2Rad * 0.5f) * pos * 2f;

            transform.localScale = new Vector3(h * cam.aspect, h, 0f);
        }

}