Unity 讓一個平面(Plane)在正交攝像頭下全屏

    public Transform clip;
    // Start is called before the first frame update
    void Start()
    {
        clip.position = Camera.main.transform.position + Camera.main.transform.forward * Camera.main.farClipPlane / 2;
        var p0 = Camera.main.ScreenToWorldPoint(Vector3.zero);
        var p1 = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height));
        clip.localScale = new Vector3
        {
            x = (p1.x - p0.x) / 10,
            y = 1,
            z = (p0.y - p1.y) / 10 
        };
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章