团结 - 无法更改分辨率 [英] Unity - Can not change resolution

查看:166
本文介绍了团结 - 无法更改分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的游戏我正在为Android分辨率设置有问题。而且,任何解决我的地方,在399x639(纵向)我试图改变在播放器设置,将自定义的分辨率和code更改,但不利于:(有没有人有一个想法,什么都可以解决始终渲染它错了?

I am having a problem with my resolution settings for a game I am making for Android. Which ever resolution I place to be rendered it always in resolution 399x639(for portrait) I tried changing in player settings, placing a custom resolution and changing it in code but does not help :( Does anyone have an idea what can be wrong?

感谢名单

推荐答案

首先,当你在编辑>项目设置>球员说,你可以更改分辨率。我想你也知道如何去改变它,而你正在开发(去上面的游戏查看吧)

To begin with, you can change the resolution as you said in Edit > Project Settings > Player. I think that you also know how to change it while you're developing (go to the bar above the Game View).

那么,你必须使游戏是独立的屏幕分辨率。为了做到这一点,你就可以开始定义这两个变量:

Well, you have to make the game to be independent of the screen resolution. For do that, you can start defining these two variables:

    nativeHeightResolution = 1200.0;
    scaledWidthResolution = nativeHeightResolution / Screen.height * Screen.width

而在OnGUI()函数,你可以这样写:

And in the OnGUI() function you can write this:

    GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (Screen.height / nativeHeightResolution, Screen.height / nativeHeightResolution, 1)); 

然后,如果你想画一个标签,比如,你可以使用这样的:

Then, if you want to draw a label, for example, you could use this:

    function Label_Center(pos : Vector2, text : String, style : GUIStyle) {  //draw a text label from the center of screen + position, with style
       GUI.Label(Rect (pos.x + scaledWidthResolution / 2, pos.y + nativeHeightResolution / 2, 700, 100), text, style);
    }

这是我在我的项目使用。我希望它一直有用的给你。

This is what I have used in my projects. I hope that it have been usefull for you.

这篇关于团结 - 无法更改分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆