Application類位于UnityEngine下涕癣,用于訪問應(yīng)用程序在運(yùn)行時(shí)的一些數(shù)據(jù)诉瓦。這個(gè)類不包含實(shí)例屬性和實(shí)例方法茬腿,這就意味著在腳本中我們直接通過Application類來調(diào)用其靜態(tài)的屬性靜態(tài)方法來控制程序運(yùn)行時(shí)的數(shù)據(jù)聚至。
為了更好的了解這個(gè)類,下面列舉了Unity官網(wǎng)提供的靜態(tài)屬性和靜態(tài)方法
靜態(tài)屬性(Static Variables)
靜態(tài)屬性 | 英文解釋 | 中文說明 |
---|---|---|
string dataPath | Contains the path to the game data folder (Read Only). | 游戲數(shù)據(jù)路徑 |
string persistentDataPath | Contains the path to a persistent data directory (Read Only). | 持久化數(shù)據(jù)路徑戴已。 |
string ** streamingAssetsPath** | Contains the path to the StreamingAssets folder (Read Only). | 流數(shù)據(jù)緩存目錄固该。 |
string temporaryCachePath | Contains the path to a temporary data / cache directory (Read Only). | 零時(shí)緩存目錄。 |
int levelCount | The total number of levels available (Read Only). | 場景的總數(shù)糖儡。 |
int loadedLevel | The level index that was last loaded (Read Only). | 當(dāng)前加載的場景序號 |
int loadedLevelName | The name of the level that was last loaded (Read Only). | 當(dāng)前加載的場景名稱伐坏。 |
bool isLoadingLevel | Is some level being loaded? (Read Only). isLoadingLevel returns true if a level load was requested this frame already. | 表示當(dāng)前加載的場景是否還需要當(dāng)前幀。 |
NetworkReachability internetReachability | Returns the type of Internet reachability currently possible on the device. | 表示當(dāng)前設(shè)備的網(wǎng)絡(luò)連接方式握联。 |
RuntimePlatform platform | Returns the platform the game is running (Read Only). | 表示當(dāng)前游戲運(yùn)行的平臺(tái)桦沉。 |
bool isConsolePlatform | Is the current Runtime platform a known console platform. | 表示當(dāng)前運(yùn)行的平臺(tái)是否為控制臺(tái)。 |
bool isMobilePlatform | Is the current Runtime platform a known mobile platform. | 當(dāng)前運(yùn)行的平臺(tái)是否為移動(dòng)平臺(tái)金闽。 |
bool isWebPlayer | Are we running inside a web player? (Read Only). | 當(dāng)前運(yùn)行的平臺(tái)是否為web平臺(tái)纯露。 |
bool isEditor | Are we running inside the Unity editor? (Read Only). | 表示當(dāng)前是否在Unity編輯器環(huán)境中運(yùn)行程序。 |
int targetFrameRate | Instructs game to try to render at a specified frame rate. | 幀速率代芜。 |
ThreadPriority **backgroundLoadingPriority ** | Priority of background loading thread. | 表示后臺(tái)加載優(yōu)先級苔埋。 |
string bundleIdentifier | eturns application bundle identifier at runtime. | 表示應(yīng)用運(yùn)行時(shí)的標(biāo)識(shí)符。 |
string cloudProjectId | A unique cloud project identifier. It is unique for every project (Read Only). | 云應(yīng)用的唯一標(biāo)識(shí)符蜒犯。 |
string companyName | Return application company name (Read Only). | 應(yīng)用的公司名稱。 |
ApplicationInstallMode installMode | Returns application install mode (Read Only). | 應(yīng)用安裝模式荞膘。 |
bool runInBackground | Should the player be running when the application is in the background? | 應(yīng)用是否在后臺(tái)運(yùn)行罚随。 |
ApplicationSandboxType sandboxType | Returns application running in sandbox (Read Only). | 應(yīng)用程序運(yùn)行的沙箱類型。 |
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). | 字節(jié)流數(shù)淘菩。 |
SystemLanguage systemLanguage | How many bytes have we downloaded from the main unity web stream (Read Only). | 當(dāng)前系統(tǒng)使用的語言。 |
string unityVersion | The version of the Unity runtime used to play the content. | Unity的版本。 |
string version | Returns application version number (Read Only). | 應(yīng)用版本潮改。 |
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瀏覽器中數(shù)據(jù)文件的絕對路徑。 |
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). | 應(yīng)用安裝模式汇在。 |
靜態(tài)方法(Static Functions)
靜態(tài)方法 | 英文解釋 | 中文說明 |
---|---|---|
void LoadLevel(int index); void LoadLevel(string name); | Loads the level by its name or index. | 根據(jù)場景名稱和索引號加載場景 |
void LoadLevelAdditive(int index);void LoadLevelAdditive(string name); | Loads a level additively. | 根據(jù)場景名稱和索引號加載場景翰萨,但是當(dāng)前場景的物體不銷毀 |
** 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. | 異步加載場景,而且當(dāng)前物體不銷毀 |
** 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. | 取消應(yīng)用退出糕殉。 |
** bool CanStreamedLevelBeLoaded(int levelIndex);** | Can the streamed level be loaded? | 獲得當(dāng)前l(fā)evelindex的場景是否被加載亩鬼。 |
** 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. | 在瀏覽器中訪問網(wǎng)址 |
** AsyncOperation RequestUserAuthorization(UserAuthorization mode);** | Request authorization to use the webcam or microphone in the Web Player. | 請求獲得權(quán)限 |
** void ExternalCall(string functionName, params object[] args);** | alls a function in the containing web page (Web Player only). | 在webplayer 調(diào)用一個(gè)javaScrip函數(shù)阿蝶。 |
** void ExternalEval(string script);** | Evaluates script snippet in the containing web page (Web Player only). | 在webplayer上執(zhí)行javascrip片段雳锋。 |
** float GetStreamProgressForLevel(int levelIndex);** | How far has the download progressed? [0...1]. | 下載進(jìn)度。 |
** bool HasUserAuthorization(UserAuthorization mode);** | pCheck if the user has authorized use of the webcam or microphone in the Web Player. | 檢測用戶是否有webcam和手機(jī)在webpalyer的權(quán)限羡洁。 |
結(jié)語
雖然以上羅列的屬性和方法官網(wǎng)API都有詳細(xì)的介紹玷过,但這里我用表格的形式展現(xiàn)出這些方法和屬性,閱讀起來更直觀筑煮,同時(shí)我將常用的放在前面辛蚊,功能相似的屬性和方法放在一塊,這樣好做一個(gè)區(qū)分和比較咆瘟。
第一篇文章就這樣寫完了嚼隘,雖然沒有寫什么實(shí)質(zhì)性的內(nèi)容,但還是感覺蠻有成就感的袒餐,最重要的是已經(jīng)邁出了第一步飞蛹,敢寫敢做,立馬行動(dòng)灸眼,以前知道寫博客文章很重要卧檐,但是遲遲沒有行動(dòng),所以說路在腳下焰宣,要敢于往前走霉囚。還有就是學(xué)會(huì)了使用markdown,一開始用的時(shí)候感覺挺不適應(yīng)的匕积,但慢慢寫下來盈罐,熟悉了語法,覺得還是挺好用的闪唆,好處不用說盅粪,誰用誰知道。
今天只是一個(gè)開始悄蕾,堅(jiān)持票顾!繼續(xù)加油!
寫于 2016年7月19 ->2016年7月20更新
深圳
young