游戏设置辅助开发-API

27次阅读

共计 1011 个字符,预计需要花费 3 分钟才能阅读完成。

野子电竞数据官网改版 https://www.xxe.io/ 全新登场

  1. Screen

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

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

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

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

// 不息屏
Screen.sleepTimeout = SleepTimeout.NeverSleep;

  1. Aplacation

关于 Application.dataPath 以及相关资源读取,推荐 Unity3D 移动平台动态读取外部文件全解析 https://www.xxe.io/

    // 设置游戏目标帧率,- 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;
  1. DateTime

       // 电量,电池状态
       float batteryLevel = SystemInfo.batteryLevel;
       string batteryStatus = SystemInfo.batteryStatus.ToString();
    
       // 设备型号、名字、类型
       string deviceModel = SystemInfo.deviceModel;
       string deviceName = SystemInfo.deviceName;
       string deviceType = SystemInfo.deviceType.ToString();
    

正文完
 0