美文网首页unityUnity技术分享Unity教程合集
Unity API——Application类的详解(一):列举

Unity API——Application类的详解(一):列举

作者: young路在脚下 | 来源:发表于2016-07-19 12:29 被阅读2497次

    Application类位于UnityEngine下,用于访问应用程序在运行时的一些数据。这个类不包含实例属性和实例方法,这就意味着在脚本中我们直接通过Application类来调用其静态的属性静态方法来控制程序运行时的数据。

    为了更好的了解这个类,下面列举了Unity官网提供的静态属性和静态方法


    静态属性(Static Variables
    静态属性 英文解释 中文说明
    string dataPath Contains the path to the game data folder (Read Only). 游戏数据路径
    string persistentDataPath Contains the path to a persistent data directory (Read Only). 持久化数据路径。
    string ** streamingAssetsPath** Contains the path to the StreamingAssets folder (Read Only). 流数据缓存目录。
    string temporaryCachePath Contains the path to a temporary data / cache directory (Read Only). 零时缓存目录。
    int levelCount The total number of levels available (Read Only). 场景的总数。
    int loadedLevel The level index that was last loaded (Read Only). 当前加载的场景序号
    int loadedLevelName The name of the level that was last loaded (Read Only). 当前加载的场景名称。
    bool isLoadingLevel Is some level being loaded? (Read Only). isLoadingLevel returns true if a level load was requested this frame already. 表示当前加载的场景是否还需要当前帧。
    NetworkReachability internetReachability Returns the type of Internet reachability currently possible on the device. 表示当前设备的网络连接方式。
    RuntimePlatform platform Returns the platform the game is running (Read Only). 表示当前游戏运行的平台。
    bool isConsolePlatform Is the current Runtime platform a known console platform. 表示当前运行的平台是否为控制台。
    bool isMobilePlatform Is the current Runtime platform a known mobile platform. 当前运行的平台是否为移动平台。
    bool isWebPlayer Are we running inside a web player? (Read Only). 当前运行的平台是否为web平台。
    bool isEditor Are we running inside the Unity editor? (Read Only). 表示当前是否在Unity编辑器环境中运行程序。
    int targetFrameRate Instructs game to try to render at a specified frame rate. 帧速率。
    ThreadPriority **backgroundLoadingPriority ** Priority of background loading thread. 表示后台加载优先级。
    string bundleIdentifier eturns application bundle identifier at runtime. 表示应用运行时的标识符。
    string cloudProjectId A unique cloud project identifier. It is unique for every project (Read Only). 云应用的唯一标识符。
    string companyName Return application company name (Read Only). 应用的公司名称。
    ApplicationInstallMode installMode Returns application install mode (Read Only). 应用安装模式。
    bool runInBackground Should the player be running when the application is in the background? 应用是否在后台运行。
    ApplicationSandboxType sandboxType Returns application running in sandbox (Read Only). 应用程序运行的沙箱类型。
    string srcValue The path to the web player data file relative to the html file (Read Only). web player 文件的路径。
    int ** streamedBytes** How many bytes have we downloaded from the main unity web stream (Read Only). 字节流数。
    SystemLanguage systemLanguage How many bytes have we downloaded from the main unity web stream (Read Only). 当前系统使用的语言。
    string unityVersion The version of the Unity runtime used to play the content. Unity的版本。
    string version Returns application version number (Read Only). 应用版本。
    int webSecurityEnabled Indicates whether Unity's webplayer security model is enabled. unity 的webplayer的安全模式是否开启。
    string absoluteURL The absolute path to the web player data file (Read Only). 用于保存在web浏览器中数据文件的绝对路径。
    bool **genuine ** Returns false if application is altered in any way after it was built.
    bool genuineCheckAvailable Contains the path to the game data folder (Read Only).
    ApplicationInstallMode installMode Returns application install mode (Read Only). 应用安装模式。
    静态方法(Static Functions

    静态方法 英文解释 中文说明
    void LoadLevel(int index); void LoadLevel(string name); Loads the level by its name or index. 根据场景名称和索引号加载场景
    void LoadLevelAdditive(int index);void LoadLevelAdditive(string name); Loads a level additively. 根据场景名称和索引号加载场景,但是当前场景的物体不销毁
    ** AsyncOperation LoadLevelAsync(int index); AsyncOperation LoadLevelAsync(string levelName);** Loads the level asynchronously in the background. 异步加载场景
    ** AsyncOperation LoadLevelAdditiveAsync(int index); AsyncOperation LoadLevelAdditiveAsync(string levelName);** Loads the level additively and asynchronously in the background. 异步加载场景,而且当前物体不销毁
    ** void Quit();** Quits the player application. 退出游戏
    ** void CancelQuit();** Cancels quitting the application. This is useful for showing a splash screen at the end of a game. 取消应用退出。
    ** bool CanStreamedLevelBeLoaded(int levelIndex);** Can the streamed level be loaded? 获得当前levelindex的场景是否被加载。
    ** void CaptureScreenshot(string filename, int superSize = 0);** Captures a screenshot at path filename as a PNG file. 截屏。
    ** void OpenURL(string url);** Opens the url in a browser. 在浏览器中访问网址
    ** AsyncOperation RequestUserAuthorization(UserAuthorization mode);** Request authorization to use the webcam or microphone in the Web Player. 请求获得权限
    ** void ExternalCall(string functionName, params object[] args);** alls a function in the containing web page (Web Player only). 在webplayer 调用一个javaScrip函数。
    ** void ExternalEval(string script);** Evaluates script snippet in the containing web page (Web Player only). 在webplayer上执行javascrip片段。
    ** float GetStreamProgressForLevel(int levelIndex);** How far has the download progressed? [0...1]. 下载进度。
    ** bool HasUserAuthorization(UserAuthorization mode);** pCheck if the user has authorized use of the webcam or microphone in the Web Player. 检测用户是否有webcam和手机在webpalyer的权限。

    结语

    虽然以上罗列的属性和方法官网API都有详细的介绍,但这里我用表格的形式展现出这些方法和属性,阅读起来更直观,同时我将常用的放在前面,功能相似的属性和方法放在一块,这样好做一个区分和比较。
      第一篇文章就这样写完了,虽然没有写什么实质性的内容,但还是感觉蛮有成就感的,最重要的是已经迈出了第一步,敢写敢做,立马行动,以前知道写博客文章很重要,但是迟迟没有行动,所以说路在脚下,要敢于往前走。还有就是学会了使用markdown,一开始用的时候感觉挺不适应的,但慢慢写下来,熟悉了语法,觉得还是挺好用的,好处不用说,谁用谁知道。
      今天只是一个开始,坚持!继续加油!

    写于 2016年7月19 ->2016年7月20更新
    深圳
    young

    相关文章

      网友评论

        本文标题:Unity API——Application类的详解(一):列举

        本文链接:https://www.haomeiwen.com/subject/uompjttx.html