游戏设置、辅助开发 API

版权声明:欢迎大家留言讨论共同进步,转载请注明出处 https://blog.csdn.net/qq_39108767/article/details/83447396

这里只是列举了小部分常用的API,详细信息可直接F12转到定义查看~

1. Screen

利用屏幕长宽,可以更完美的实现UI的适配

//屏幕分辨率
Resolution resolution = Screen.currentResolution;

//游戏运行时全屏
Screen.fullScreen = true;

//屏幕高度,宽度
int screenHeight = Screen.height;
int screenWidth = Screen.width;

2. Aplacation

关于Application.dataPath以及相关资源读取,推荐Unity3D移动平台动态读取外部文件全解析 (https://www.cnblogs.com/murongxiaopifu/p/4199541.html)

        //设置游戏目标帧率,-1表示不限制,使用最快帧率
        Application.targetFrameRate = -1;
        
        //用浏览器打开链接
        Application.OpenURL("URL");
        
        //退出APP
        Application.Quit();

        // Assets文件夹路径
        string path = Application.dataPath;

        //设置是否后台运行
        Application.runInBackground = true;

        //获取系统语言
        SystemLanguage systemLanguage = Application.systemLanguage;

        //获取版本号
        string unityVersion = Application.version;

        //网络类型(无网络/3G4G/WIFI)
        NetworkReachability networkReachability = Application.internetReachability;

3. DateTime

        //电量,电池状态
        float batteryLevel = SystemInfo.batteryLevel;
        string batteryStatus = SystemInfo.batteryStatus.ToString();

        //设备型号、名字、类型
        string deviceModel = SystemInfo.deviceModel;
        string deviceName = SystemInfo.deviceName;
        string deviceType = SystemInfo.deviceType.ToString();

后续继续补充~~

猜你喜欢

转载自blog.csdn.net/qq_39108767/article/details/83447396