unity打包全屏显示以及Unity的一些打包设置 |
您所在的位置:网站首页 › 游戏界面怎么全屏快捷键设置 › unity打包全屏显示以及Unity的一些打包设置 |
这里介绍两种全屏显示的方法。第一种是写代码实现的可以外部载入数据并且修改分辨率。 using RenderHeads.Media.AVProVideo; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System.Xml; using System.Text; using System; using System.Runtime.InteropServices; public class GameControl : MonoBehaviour { [DllImport("user32.dll")] static extern IntPtr SetWindowLong(IntPtr hwnd, int _nIndex, int dwNewLong); [DllImport("user32.dll")] static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); [DllImport("user32.dll")] static extern IntPtr GetForegroundWindow(); [DllImport("User32.dll", EntryPoint = "GetSystemMetrics")] public static extern IntPtr GetSystemMetrics(int nIndex); const int SM_CXSCREEN = 0x00000000; const int SM_CYSCREEN = 0x00000001; const uint SWP_SHOWWINDOW = 0x0040; const int GWL_STYLE = -16; const int WS_BORDER = 1; const int WS_POPUP = 0x800000; //float x = mycamera.WorldToScreenPoint(kongjian.transform.position).x; //float y = mycamera.WorldToScreenPoint(kongjian.transform.position).y; //x,y即为控件在屏幕的坐标camera.WorldToScreenPoint()方法返回的是一个position类型 是vector3类型,camera为要转化到的目标摄像机,传入的参数为控件的世界坐标 void Start() { //bool result = SetWindowPos(GetForegroundWindow(), 0, winPosX, winPosY, winWidth, winHeight, SWP_SHOWWINDOW); //测试发现左下角坐标为(0,1),修改如下 string a = ReadALine(FileName, 1);//读取第一行 string b = ReadALine(FileName, 2);//读取第二行 //string c = ReadALine(FileName, 3);//读取第三行 //string d = ReadALine(FileName, 4);//读取第四行 string e = ReadALine(FileName, 3);//读取第四行 string f = ReadALine(FileName, 4);//读取第四行 //转换成Int值 VideoOnePosX = int.Parse(a); VideoOnePosY = int.Parse(b); //VideoTowPosX = int.Parse(c); //VideoTowPosY = int.Parse(d); Weight= int.Parse(e); Height = int.Parse(f); VideoOnePos.anchoredPosition = new Vector3(VideoOnePosX, VideoOnePosY, 0);//设置屏幕位置 //VideoTowPos.anchoredPosition = new Vector3(VideoTowPosX, VideoTowPosY, 0);//设置屏幕位置 //Debug.Log(VideoOnePos.anchoredPosition); //Debug.Log(VideoTowPos.anchoredPosition); //SetWindowLong(GetForegroundWindow(), GWL_STYLE, WS_POPUP); //测试发现左下角坐标为(0,1),修改如下 //bool result = SetWindowPos(GetForegroundWindow(), 0, 0, 0, Weight, Height, SWP_SHOWWINDOW); } //读取文本某一行字符串 string ReadALine(string FileName, int linenumber) // 参数1:打开的文件(路径+文件命),参数2:读取的行数 { string[] strs = File.ReadAllLines(FileName); if (linenumber == 0) { return "0"; } else { return strs[linenumber - 1]; } } // Update is called once per frame void Update () { //Screen.SetResolution(Weight, Height, true);//这是设置屏幕分辨率的方法,后面的false表示非全屏 //SetWindowPos(GetForegroundWindow(), 0, PosX, PosY,100, 100, 0x001); } } }但是这种方式有一个问题就是打包出来屏幕周边会有一些白边。下面是一种外部通过创建快捷键来设置屏幕全屏的方式: 创建exe快捷方式后点击快捷键属性 复制下面代码到 exe 后面空格也要复制进去 -screen-width 2590 -screen-height 768 -popupwindow 这种方式简单方便,当然Unity中的也有设置全屏的,但是适用于单屏,分辨率改变的额话会有一些问题。 file->buildSetting->playersetting 如上图:首先是company name 和product name,即公司名字和产品名字,然后是default icon,就是生成的文件图标。 对于1部分: Resolution and presentation展开后为: |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |