为什么unityui设置为unity 竖屏开发后,app中界面变形

ios启动页强制竖屏(进入App后允许横屏与竖屏)
作者:Stevenzhai
字体:[ ] 类型:转载 时间:
最近工作遇到这样一个需要,当进入启动页需要强制竖屏,而进入APP后就允许横屏与竖屏,通过查找相关的资料找到了解决的方法,所以将实现的方法整理后分享出来,需要的朋友们可以参考借鉴,下面来一起看看吧。
这篇文章主要介绍了在ios启动页强制竖屏,进入App后允许横屏与竖屏的相关资料,需要的朋友可以参考下。
1、修改App-info.plist(在XCode中General中设置 一样的效果)
&key&UISupportedInterfaceOrientations&/key&
&string&UIInterfaceOrientationPortrait&/string&
2、AppDelegate中:
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAllButUpsideD
贴一下苹果对这个的解释,可以放心使用:
Discussion
This method returns the total set of interface orientations supported by the app. When determining whether to rotate a particular view controller, the orientations returned by this method are intersected with the orientations supported by the root view controller or topmost presented view controller. The app and view controller must agree before the rotation is allowed.
If you do not implement this method, the app uses the values in the UIInterfaceOrientation key of the app's Info.plist as the default interface orientations.
以上就是这篇文章的全部内容了,希望本文的内容对各位iOS开发者们能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对脚本之家的支持。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具3682人阅读
unity3D(65)
在了解全屏问题之前必须要知道两个方法:Screen.SetResolution()和&Screen.fullScreen =&
Screen.fullScreen =是设置为全屏的代码。
看官网对Screen.SetResolution()解释和例子:
看完这个就已经知道了这个方法就是设置固定分辨率下是否全屏的方法。官网的第一个例子就是640*480分辨率下的全屏,第二个例子是以60hz的速率转化为640*480的全屏(默认情况这个preferredRefreshRate=0);第三个例子是800*600分辨率但不全屏。
用一个实例来看:
首先建立一个工程,里面有3d场景也有UI界面,UI一定要把锚点设置好。
然后写一个脚本:
using UnityE
using System.C
public class fullscreen : MonoBehaviour {
// Use this for initialization
void Start () {
// Update is called once per frame
void Update () {
按ESC退出全屏
if(Input.GetKey(KeyCode.Escape))
Screen.fullScreen =
//退出全屏
//设置为不全屏
if (Input.GetKey(KeyCode.V))
Screen.SetResolution(, false);
//设置的全屏
if (Input.GetKey(KeyCode.B))
Screen.SetResolution(, true);
if (Input.GetKey(KeyCode.A))
//获取设置当前屏幕分辩率
Resolution[] resolutions = Screen.
//设置当前分辨率
Screen.SetResolution(resolutions[resolutions.Length - 1].width, resolutions[resolutions.Length - 1].height, true);
Screen.fullScreen =
//设置成全屏,
这段代码中最后一个方法是最为实用的方法,因为它实用于任何分辨率的显示器来显示全屏,不会出现拉伸的效果。Screen.fullScreen = true;这个是unity全屏代码。
下面是运行效果图:
默认效果:
按B键全屏时,画面出现了拉伸
按A键全屏,不出现拉伸:
按ESC退出全屏回归默认大小。
按V键会设置为的大小。
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:154835次
积分:2993
积分:2993
排名:第11045名
原创:139篇
转载:40篇
评论:27条
(1)(1)(1)(1)(2)(14)(11)(14)(10)(4)(1)(4)(1)(1)(5)(3)(2)(6)(2)(4)(13)(6)(8)(6)(2)(18)(41)unity3d编写设置界面后回不到主界面怎么办?_unity吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:21,807贴子:
unity3d编写设置界面后回不到主界面怎么办?收藏
下面是代码,只要我按下返回按钮就蓝屏了,返回不到主界面Welcomevar Tex:Texture2D;//背景图片var Tex1:Texture2D;//版权与版本信息图片var bu1:Texture2D;//确定按钮图片var bu2:Texture2D;//返回按钮图片var MyStyle:GUIS//按钮填充样式var wbili=1.0f;//横向缩放比例var hbili=1.0f;//纵向缩放比例function OnGUI(){wbili=Screen.width/1024.0;//得到横向缩放比例hbili=Screen.height/576.0;//得到纵向缩放比例GUI.DrawTexture(Rect(0,0,1024*wbili,576*hbili),Tex); //绘制背景GUI.DrawTexture(Rect(280*wbili,50*hbili,500*wbili,500*hbili),Tex1);//绘制版权与版本信息if(GUI.Button(Rect(150*wbili,450*hbili,180*wbili,90*hbili),bu1,MyStyle)){//确定按钮被按下Application.LoadLevel("welcome");//返回主菜单界面}if(GUI.Button(Rect(800*wbili,450*hbili,190*wbili,90*hbili),bu2,MyStyle)){//返回按钮被按下Application.LoadLevel("Welcome");//返回主菜单界面}}function Update(){
if(Input.GetKeyDown(KeyCode.Escape)){//手机下端的返回键被按下Application.LoadLevel("Welcome");//返回主界面}}
登录百度帐号推荐应用}

我要回帖

更多关于 unity pc 竖屏 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信