unity 屏幕填充问题(有黑边)

让程序填充全屏

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FullScreen : MonoBehaviour
{
    private void Awake()
    {
        print("**");
        SetFullScreen();
    }
    
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            SetFullScreen();
        }
    }

    public void SetFullScreen()
    {
        //获取设置当前屏幕分辩率 
        Resolution[] resolutions = Screen.resolutions;
        //设置当前分辨率 
        Screen.SetResolution(resolutions[resolutions.Length - 1].width, resolutions[resolutions.Length - 1].height, true);

        Screen.fullScreen = true;  //设置成全屏

    }
}
posted @ 2022-06-22 18:04  哒哒哒~~~  阅读(223)  评论(0编辑  收藏  举报