屏幕自适应
来源:互联网 发布:tensorflow 最好的书 编辑:程序博客网 时间:2024/05/17 08:16
public class WindowsRoot : MonoBehaviour{ public static float DesignWidth = 1280.0f;public static float DesignHeight = 720.0f;static float mManualHeight = 720.0f;public static float ManualHeight { get{ return mManualHeight;} set{ mManualHeight = value;}}// Use this for initializationvoid Start () { Application.targetFrameRate = 30;//Screen.SetResolution(1280, 800, true); //Screen.SetResolution(300, 200, true); float designRatio = DesignWidth / DesignHeight; float actualRatio = (float)Screen.width / (float)Screen.height; //物理屏幕分辨率与游戏设计分辨率比。 float ratioOf = DesignWidth / Screen.width; //只缩小,不放大. float ratioScale = Mathf.Min(ratioOf, 1f); //锁定分辨率,最大不超过DesignWidth 和 DesignHeight. Screen.SetResolution(Mathf.FloorToInt(Screen.width * ratioScale), Mathf.FloorToInt(Screen.height * ratioScale), true);Debug.Log("designRatio = " + designRatio);Debug.Log("actualRatio = " + actualRatio);UIRoot UIRoot = GetComponent<UIRoot>();mManualHeight = UIRoot.manualHeight;Debug.Log( "mManualHeight = " + mManualHeight); if (actualRatio < designRatio){ UIRoot.manualHeight = (int)Mathf.Round( UIRoot.manualHeight * designRatio / actualRatio );mManualHeight = UIRoot.manualHeight;Debug.Log( "mManualHeight = " + mManualHeight); }GameObject.DontDestroyOnLoad(this);} //void OnUpdate(string msg)void Update(){}}
0 0
- 屏幕自适应
- 屏幕自适应
- 屏幕自适应
- 屏幕自适应
- 自适应屏幕
- 屏幕自适应
- 屏幕自适应
- 屏幕自适应
- cocos2dx屏幕屏幕自适应
- android 屏幕自适应问题
- Silverlight 自适应屏幕大小
- silverlight自适应屏幕
- WebView自适应屏幕宽度
- Div 自适应屏幕大小
- WebView自适应屏幕大小
- android:屏幕自适应问题
- android屏幕自适应研究
- [Android]屏幕自适应布局
- python writelines()函数
- 个人对插件和钩子的理解
- (未完成)Dubbo源码分析(七):Dubbo内核实现之基于SPI思想Dubbo内核实现
- Codeforce 149D(区间dp+括号匹配)
- 1001 of dp
- 屏幕自适应
- poj 1840 Eqs
- 128. Longest Consecutive Sequence
- mongodb数据库基本操作
- linux 常用设置和命令
- 小程序:或与加
- php与MySQL的连接
- ViewPager和Fragment结合使用,可以做出顶部导航界面滑动效果
- web项目异常A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister