您当前的位置: 首页 >  unity

unity工具人

暂无认证

  • 3浏览

    0关注

    205博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

unity工具人 发布时间:2021-07-28 22:06:58 ,浏览量:3

让程序填充全屏

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;  //设置成全屏

    }
}
关注
打赏
1656671177
查看更多评论
立即登录/注册

微信扫码登录

0.0371s