Unity API——Application类的详解(一):列举属性和方法

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,219评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,363评论 1 293
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,933评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,020评论 0 206
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,400评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,640评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,896评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,597评论 0 199
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,327评论 1 244
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,581评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,072评论 1 261
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,399评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,054评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,083评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,849评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,672评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,585评论 2 270

推荐阅读更多精彩内容