版本 |
作者 |
参与者 |
完成日期 |
备注 |
UnityAPI_Application_V01_1.0 |
严立钻 |
|
2020.05.12 |
|
|
|
|
|
|
立钻哥哥:Unity是一个入门快、提高难的游戏引擎,想要提升能力,至少需要越过3道坎:API+Shader+综合能力;++1、API的积累:对API的合理利用不仅可以减轻自己的编码负担,而且往往可以提高程序的运行效率;这也是钻哥开始“Unity API”独立打造分类的初衷; ++2、Shader编程:想要做出一款精品游戏往往需要有高效的Shader的支持;Unity提供了一套改良的“Shader Lab”系统,优化了繁杂的“Open GL”编程; ++3、综合能力(技术+业务+管理):一款产品的制作除了功能编程外,往往会涉及很多其他领域,例如产品架构、UI交互设计、模型制作等,作为主要的编程人员,对其他相关领域的了解程序往往会影响到产品制作直至最后的产品体验; ++++立钻哥哥一直在推动【VR云游戏=Unity+SteamVR+云技术+5G+AI】,这个只是一个引子,抛砖引玉让大家对整个知识体系有一个明确的落地方向,宝宝们可以根据自己的兴趣方向进行拓展:比如Unity这里是指一种“3D游戏引擎”,也可拓展至“UE4、Cocos2dx”等游戏引擎;SteamVR是一种跨硬件解决方案,也可拓展至“VRTK”等第三方插件;“云技术+5G”是一种跨平台解决方案的核心技术,同样可拓展至其他平台解决方案;AI也是一种先进技术的举例,也可以拓展至任何一种前沿技术; |
++++【Unity开发基础】分类:https://blog.csdn.net/vrunsoftyanlz/category_7309057.html
++++【Linux系统编程】分类:https://blog.csdn.net/vrunsoftyanlz/category_9694767.html
++++【C++C铸就生存利器】分类:https://blog.csdn.net/vrunsoftyanlz/category_9325802.html
++++【人工智能AI2026】分类:https://blog.csdn.net/vrunsoftyanlz/category_9212024.html
++++【立钻哥哥CSDN空间】:https://blog.csdn.net/VRunSoftYanlz/
#Application应用程序 |
#Application应用程序++A1、Description描述++B2、Variables变量++C3、Public Function共有函数++D4、Message消息 |
#A1、Description描述 |
#B2、Static Variables变量 |
++B2、Static Variables变量++++B2.1、absoluteURL++++B2.2、backgroundLoadingPriority++++B2.3、dataPath++++B2.4、genuine++++B2.5、genuineCheckAvailable++++B2.6、internetReachability++++B2.7、isEditor++++B2.8、idLoadingLevel++++B2.9、isPlaying++++B2.10、isWebPlayer++++B2.11、levelCount++++B2.12、loadedLevel++++B2.13、loadedLevelName++++B2.14、persistentDataPath++++B2.15、platform++++B2.16、runInBackground++++B2.17、srcValue++++B2.18、streamedBytes++++B2.19、streamingAssetsPath++++B2.20、systemLanguage++++B2.21、targetFrameRate++++B2.22、temporaryCachePath++++B2.23、unityVersion++++B2.24、webSecurityEnabled++++B2.25、YanlzAPI.Application.StaticVariables |
++B2.1、absoluteURL |
static string absoluteURL; |
++++Application.absoluteURL和Application.srcValue允许检测unityWeb数据文件是否被移动或链接到其他位置;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void Start(){ bool isPirated = false;
if(Application.isWebPlayer){ if(Application.srcValue != “game.unity3d”){ isPirated = true; }
if(string.Compare(Application.absoluteURL, “http://www.i360game.com/Game/game.unity3d”, true) != 0){ isPirated = true; }
if(isPirated){ print(“立钻哥哥:Pirated web player!”); } } //立钻哥哥:if(){}
} //立钻哥哥:void Start(){} } //立钻哥哥:public class YanlzApplication{} |
++B2.2、backgroundLoadingPriority |
static ThreadPriority backgroundLoadingPriority; |
++++控制需要多长时间来异步加载数据,在后台加载游戏;
unity UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyAppFunc(){ Application.backgroundLoadingPriority = ThreadPriority.High; //Application.backgroundLoadingPriority = ThreadPriority.Low; } } //立钻哥哥:public class YanlzApplication{} |
++B2.3、dataPath |
static string dataPath; |
++++这个值依赖于运行的平台;
++++[Unity编辑器]:<工程文件夹的路径>/Assets;
++++[Mac player]:<播放器应用的路径>/Contents;
++++[iPhone player]:<播放器应用的路径>/
++++[Win player]:<包含可执行播放器的文件夹的路径>\Data;
++++[Web player]:播放器数据文件夹的绝对路径(没有实际的数据文件名称);
++++[Flash]:播放器数据文件夹的绝对路径(没有实际的数据文件名称);
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ public void Awake(){ print(Application.dataPath); } } //立钻哥哥:public class YanlzApplication{} |
++B2.4、genuine |
static bool genuine; |
++++如果编译后的应用程序被任何方式改变的了,返回假;否则返回真;
++B2.5、genuineCheckAvailable |
static bool genuineCheckAvailable; |
++++如果可以确认应用程序的完整性返回真;否则返回假;
++B2.6、internetReachability |
static NetworkReachability internetReachability; |
++++返回设备上的网络可达性目前可能的类型;
++++此属性是在手持设备上区分运营商网络快速而廉价的WiFi连接最有用;
++++注意:请不要使用此属性来确定实际的连接;例如该设备可以连接到一个热点,但不具有连网络的实际路由;非手持设备被认为总是能够联网;
++B2.7、isEditor |
static bool isEditor; |
++++是否在Unity编辑器内运行?
++++如果游戏从Unity编辑器中运行,返回真;如果从其他部署目标运行返回假;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ if(Application.isEditor){ print(“立钻哥哥:We are running this from inside of the editor!”); } } } //立钻哥哥:public class YanlzApplication{} |
++B2.8、isLoadingLevel |
static bool isLoadingLevel; |
++++方法LoadLevel和LoadLevelAdditive不会立即生效;一个新的场景在当前游戏帧完成之后被加载;如果一个被请求加载场景的帧已经完成了,那么isLoadingLevel返回值为true;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ print(Application.isLoadingLevel); } } //立钻哥哥:public class YanlzApplication{} |
++B2.9、isPlaying |
static bool isPlaying; |
++++当在任何种类的播放器时,返回真(只读);
++++在Unity编辑器中,如果处于播放模式时返回真;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ if(Appliction.isPlaying){ print(“立钻哥哥:In player or playmode!”); } } } //立钻哥哥:public class YanlzApplication{} |
++B2.10、isWebPlayer |
static bool isWebPlayer; |
++++是否在一个网络播放器中运行?(只读)
++++如果这个游戏在Unity网络播放器中运行则返回真;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ if(Application.isWebPlayer){ print(“立钻哥哥:We are running this from inside of the web player!”); } } } //立钻哥哥:public class YanlzApplication{} |
++B2.11、levelCount |
static int levelCount; |
++++可用的关卡总数(只读);
using UnityEngine; using System.Collection;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Application.LoadLevel(Random.Range(0, Application.levelCount - 1)); } } //立钻哥哥:public class YanlzApplication{} |
++B2.12、loadedLevel |
static int loadedLevel; |
++++最后加载的关卡索引(只读),也就是已加载的关卡或上次加载的关卡索引;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Debug.Log(Application.loadedLevel); } } //立钻哥哥:public class YanlzApplication{} |
++B2.13、loadedLevelName |
static string loadedLevelName; |
++++最后加载的关卡的名字(只读);也就是已加载的或上次加载的关卡名称;
++++注意:这个值仅是由Application.LoadLevel和Application.LoadLevelAsync设置;附加的版本添加内容到当前的关卡;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Debug.Log(Application.loadedLevelName); } } //立钻哥哥:public class YanlzApplication{} |
++B2.14、persistentDataPath |
static string persistentDataPath; |
++++包含一个持久数据目录的路径(只读);
++++这个值是个目录路径,可以保存运行时要储存的数据;当发布的iOS和Android,persistentDataPath将指向设备上的公共目录;在这个位置的文件每当应用程序更新将不会被删除;然而,应该记住,针对用户行为这不是万无一失;例如,取出SD卡时会使存储的数据无法访问;
++++注意:当编译应用程序,基于包标识符将生成一个GUID,并且这个GUID也是persistentDataPath的一部分;如果在将来的版本保持相同的包标识符,那么该应用程序将继续在每次更新访问相同的位置;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Debug.Log(Application.persistentDataPath); } } //立钻哥哥:public class YanlzApplication{} |
++B2.15、platform |
static RuntimePlatform platform; |
++++返回游戏运行的平台(只读);
++++如果要做一些平台相关的操作使用这个属性;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void Start(){ if(Application.platform == RuntimePlatform.WindowsPlayer){ Debug.Log(“立钻哥哥:Do Something special here!”); } } } //立钻哥哥:public class YanlzApplication{} |
++B2.16、runInBackground |
static bool runInBackground; |
++++应用程序在后台时是否应该被运行?
++++默认为假(当程序在后台时暂停);
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestApplication(){ Application.runInBackground = true; } } //立钻哥哥:public class YanlzApplication{} |
++B2.17、srcValue |
static string srcValue; |
++++相对于html文件的web播放器数据文件的路径(只读);
++++这是被写到html文件中的路径,它是作为object的src参数和embed标签;因此如果它是绝对url,srcValue将含有绝对路径;
++++Application.absoluteURL和Application.srcValue允许检测unityWeb数据文件是否被移动或链接到其他位置;想保护这两者来阻止盗用数据文件的行为;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void Start(){ bool isPirated = false;
if(Application.isWebPlayer){ if(Application.srcValue != “game.unity3d”){ isPirated = true; }
if(string.Compare(Application.absoluteURL, “http://www.i360game.com/Game/game.unity3d”, true) != 0){ isPirated = true; }
if(isPirated){ print(“立钻哥哥:Pirated web player!”); } } //立钻哥哥:if(){}
} //立钻哥哥:void Start(){} } //立钻哥哥:public class YanlzApplication{} |
++B2.18、streamedBytes |
static int streamedBytes; |
++++我们从主Unity网页流中下载了多少字节(只读);
++++在web播放器中将返回到目前为止已经下载的压缩字节数;在PC或编辑器中总是返回零;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void Update(){ guiText.text = “立钻哥哥:Streamed Bytes: ” + Application.streamedBytes.ToString(); } } //立钻哥哥:public class YanlzApplication{} |
++B2.19、streamingAssetsPath |
static string streamingAssetsPath; |
++++包含一个到StreamingAssets文件夹的路径(只读);
++++如果在编辑项目中有个“StreamingAssets”文件夹,它将拷贝其中的内容到Application.streamingAssetsPath给出的路径;
++++注意:在某些平台,不能直接访问StreamingAssets文件夹,因为在web平台没有文件系统,在Android被压缩到.apk文件中;在另外平台,将返回url,可以使用WWW类访问使用;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ public string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, “MyFile”); public string result = “”;
IEnumerator MyTestFuc(){ if(filePath.Contains(“://”)){ WWW www = new WWW(filePath); yield return www; result = www.text; }else{ result = System.IO.File.ReadAllText(filePath); } } //立钻哥哥:IEnumerator MyTestFunc(){}
} //立钻哥哥:public class YanlzApplication{} |
++B2.20、systemLanguage |
static SystemLanguage systemLanguage; |
++++用户操作系统正在运行的语言;
++++可以用它来自动选择基于用户的系统语言的内容本地化;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ guiText.text = Application.systemLanguage.ToString(); } } //立钻哥哥:public class YanlzApplication{} |
++B2.21、targetFrameRate |
static int targetFrameRate; |
++++命令游戏尝试以一个特定的帧率渲染;
++++设置targetFrameRate为-1(默认)使独立版游戏尽可能快的渲染,并且web播放器游戏以50~60帧/秒渲染,取决于平台;
++++注意:设置targetFrameRate不会保证帧率,会因为平台的不同而波动,或者因为计算机太慢而不能取得这个帧率;
++++如果在质量设置中vsync被设置,目标帧速率会被忽略并使用vblank interval来替代;在质量设置中的vBlankCount属性用来限制帧率到屏幕刷新率的一半(通过设置vBlankCount到2屏幕60fps能被限制到30fps);
++++在编辑器中targetFrameRate被忽略;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void Awake(){ Application.targetFrameRate = 300; } } //立钻哥哥:public class YanlzApplication{} |
++B2.22、temporaryCachePath |
static string temporaryCachePath; |
++++包含一个临时数据/缓存目录的路径(只读);
++++该值是一个目录路径,临时数据可以被保存;
using UnityEngine; using System.Colletions;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Debug.Log(Application.temporaryCachePath); } } //立钻哥哥:public class YanlzApplication{} |
++B2.23、unityVersion |
static string unityVersion; |
++++用于播放该内容的Unity运行时的版本;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Debug.Log(“立钻哥哥:Version of the runtime: ” + Application.unityVersion); } } //立钻哥哥:public class YanlzApplication{} |
++B2.24、webSecurityEnabled |
static bool webSecurityEnabled; |
++++只是是否webplayer的安全模式是否被启用;
++++在Web播放器,这将始终返回true;在Unity编辑器中,如果启用了Web安全模式(Menu->Edit->Project Settings->Editor)则返回真,如果没有启用则返回假;在所有其他平台,这将返回false,此属性智能被读取;
++C3、Static Functions静态函数 |
++C3、Static Functions静态函数++++C3.1、CancelQuit++++C3.2、CanStreamedLevelBeLoaded++++C3.3、CaptureScreenshot++++C3.4、ExternalCall++++C3.5、ExternalEval++++C3.6、GetStreamProgressForLevel++++C3.7、HasProLicense++++C3.8、HasUserAuthorization++++C3.9、LoadLevel++++C3.10、LoadLevelAdditive++++C3.11、LoadLevelAdditiveAsync++++C3.12、LoadLevelAsync++++C3.13、OpenURL++++C3.14、Quit++++C3.15、RegisterLogCallback++++C3.16、RegisterLogCallbackThreaded++++C3.17、RequestUserAuthorization++++C3.18、YanlzAPI.Application.StaticFunctions |
++C3.1、CancelQuit |
static void CancelQuit(); |
++++取消退出该应用程序;这可以用来在退出游戏的时候显示一个退出画面;
++++这个函数只工作在播放器中,在Web播放器或编辑器中不做任何事;
++++注意:这个函数在iPhone中没有效果,应用程序无法阻止在iPhone OS的终止;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour(){ public float showSplashTimeout = 2.0F; private bool allowQuitting = false;
void Awake(){ DontDestroyOnLoad(); }
void OnApplicationQuit(){ if(Application.loadedLevelName.ToLower() != “YanlzFinalsplashScene”){ StartCoroutine(“YanlzDelayedQuit”); }
if(!allowQuitting){ Application.CancelQuit(); } } //立钻哥哥:void OnApplicationQuit(){}
IEnumerator YanlzDelayedQuit(){ Application.LoadLevel(“YanlzFinalsplashScene”); yield return new WaitForSeconds(showSplashTimeout); allowQuitting = true; Application.Quit(); } //立钻哥哥:IEnumerator YanlzDelayedQuit(){}
} //立钻哥哥:public class YanlzApplication{} |
++C3.2、CanStreamedLevelBeLoaded |
static bool CanStreamedLevelBeLoaded(int levelIndex);static bool CanStreamedLevelBeLoaded(string levelName); |
++++可以流数据加载关卡吗?
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void Update(){ if(Application.CanStreamedLevelBeLoaded(1)){ Application.LoadLevel(1); } } } //立钻哥哥:public class YanlzApplication{}
|
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void Update(){ if(Application.CanStreamedLevelBeLoaded(“YanlzTestLevel01Scene”)){ Application.LoadLevel(“YanlzTestLevel01Scene”); } } } //立钻哥哥:public class YanlzApplication{} |
++C3.3、CaptureScreenshot |
static void CaptureScreenshot(string filename, int superSize = 0); |
++++[filename]:保存截图文件的路径名;
++++[superSize]:提高分辨率系数;
++++捕捉屏幕到filename路径,保存为PNG文件;
++++如果文件已经存在,将会覆盖;如果在webplayer这个函数什么也不会做;在手机平台filename取决于persistentDataPath;
++++当superSize参数大于1,将会生成较大的分辨率;例如,输入4将产生被标准4*4倍大的;这截图通常用于印刷;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void OnMouseDown(){ Application.CaptureScreenshot(“MyScreenshot.png”); } } //立钻哥哥:public class YanlzApplication{} |
++C3.4、ExternalCall |
static void ExternalCall(string functionName, params object[] args); |
++++调用一个包含在网页中的函数(只用于Web Player);
++++调用包含在网页中名为functionNameJavaScript函数,并传递给定的参数;支持原始的数据类型(string, int, float, char)和这些类型的数字;如果其他的对象被转化为字符串(使用ToString方法)并作为字符串传递;
++++这个函数调用时不会被阻塞,即ExternalCall立即返回的功能而不必等待被完成;
++++传递的参数数量是可变的;
++++被调用的在HTML中的函数只需要使用标准的语法即可;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Application.ExternalCall(“MyFunc01”); Application.ExternalCall(“MyFunc02”, “立钻哥哥:Hello from Unity!”); Application.ExternalCall(“MyFunc03”, “one”, 2, 3.0F); } } //立钻哥哥:public class YanlzApplication{} |
++C3.5、ExternalEval |
static void ExternalEval(string script); |
++++调用包含在网页中的片段脚本函数(只用于Web Player);
++++这将执行包含在网页中JavaScript片段script;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Application.ExternalEval(“history.back()”); } } //立钻哥哥:public class YanlzApplication{} |
++C3.6、GetStreamProgressForLevel |
static float GetStreamProgressForLevel(int levelIndex);static float GetStreamProgressForLevel(string levelName); |
++++下载的进度是多少?
++++在Web播放器中将返回这个关卡的进度;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ public float percentageLoaded = 0;
void Update(){ if(Application.GetStreamProgressForLevel(1) == 1){ guiText.text = “立钻哥哥:Level at index 1 has fully streamed!”; }else{ percentageLoaded = Application.GetStreamProgressForLevel(1) * 100; guiText.text = percentageLoaded.ToString(); } } //立钻哥哥:void Update(){}
} //立钻哥哥:public class YanlzApplication{} |
++C3.7、HasProLicense |
static bool HasProLicense(); |
++++是具有Unity Pro许可证激活码?
++C3.8、HasUserAuthorization |
static bool HasUserAuthorization(UserAuthorization mode); |
++++检查用户是否有权在网页中使用摄像头和麦克风;
++++用来检查Application.RequestUserAuthorization调用的结果;在网页播放器必须用户明确同意使用该功能;在其他编译目标平台,该函数总是返回真;
++C3.9、LoadLevel |
static function LoadLevel(int index);static void LoadLevel(string name); |
++++[index]:要加载的关卡索引;
++++[name]:要加载的关卡的名称;
++++通过关卡的名字或索引来加载关卡;
++++在能够加载关卡之前必须将它添加到游戏使用的关卡列表中;在Unity中使用【File->Build Settings ...】,并添加需要的关卡到关卡列表中;关卡被加载所有激活物体上的MonoBehaviou.OnLevelWasLoaded都被调用;
++++当加载新的关卡时,所有已经加载的游戏物体都将被销毁;如果想让物体在加载新关卡时不被销毁,使用Object.DontDestroyOnLoad;调用LoadLevel将更新Application.loadedLevel和Application.loadedLevelName;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Application.LoadLevel(“YanlzTestScene”); } } //立钻哥哥:public class YanlzApplication{} |
++C3.10、LoadLevelAdditive |
static void LoadLevelAdditive(int index);static void LoadLevelAdditive(string name); |
++++累加一个关卡,也就是说,加载一个新的场景,当前场景不会被销毁;
++++不像LoadLevel,LoadLevelAdditive不销毁当前关卡的物体;物体从新的关卡添加到当前的场景;这对创建连续的虚拟世界很有用,在漫步环境,更多的内容被加载进来;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void MyTestFunc(){ Application.LoadLevel(1); Application.LoadLevelAdditive(“YanlzTestSceneMoreStuff”); } } //立钻哥哥:public class YanlzApplication{} |
++C3.11、LoadLevelAdditiveAsync |
static AsyncOperation LoadLevelAdditiveAsync(int index);static AsyncOperation LoadLevelAdditiveAsync(string levelName); |
++++在后台异步累加关卡,也就是说在后台非同步加载新的场景,但当前的场景不会被销毁;
++++LoadLevelAsync()和LoadLevelAdditiveAsync()的不同在于,前者最终加载完成后,上一个场景内容会被卸载,而后者是两者重叠到一起;
++++不像LoadLevelAsync,LoadLevelAdditiveAsync不销毁当前关卡的物体;物体从新的关卡添加到当前的场景;这对创建连续的虚拟世界很有用,在漫步环境,更多的内容被加载进来;
++++Unity将在后台线程完整加载场景所有资源和物体;这允许加载一个新的关卡,同时当前的关卡仍在运行,显示进度条或者创建一个完整的流世界,在不断的加载和卸载基于程序位置不同的部分,在游戏中不会有任何的中断;
++++isDone变量来自AsyncOperation异步操作的结果,可以用于如果关卡加载完成的查询;LoadLevelAdditiveAsync的结果也能在用来yield一个协同程序;
++++当编译一个游戏Unity自动优化资源,LoadLevelAsync将从硬盘以线性加载它们避免从磁盘寻道时间;
++++注意:背景加载优先级在Unity编辑器远远低于网络播放器或独立版编译;在编译器或许比播放器更多的加载中断;
++++这个函数需运行在Unity专业版;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ IEnumerator Start(){ AsyncOperation async = Application.LoadLevelAdditiveAsync(“YanlzTestLevel01”); yield return async; Debug.Log(“立钻哥哥:Loading complete!”); } } //立钻哥哥:public class YanlzApplication{} |
++C3.12、LoadLevelAsync |
static AsyncOperation LoadLevelAsync(int index);static AsyncOperation LoadLevelAsync(string levelName); |
++++在后台异步加载关卡,也就是说,在后台非同步加载新的场景;
++++Unity将在后台线程完整加载场景所有资源和物体;这允许加载一个新的关卡,同时当前的关卡仍在运行,显示进度条或者创建一个完整的流世界,在不断的加载和卸载基于程序位置不同的部分,在游戏中不会有任何的中断;
++++isDone变量来自AsyncOperation异步操作的结果,可以用于如果关卡加载完成的查询;
++++当编译一个游戏Unity自动优化资源,LoadLevelAsync将从硬盘以线性加载它们避免从磁盘寻道时间;
++++注意:背景加载优先级在Unity编辑器远远低于网络播放器或独立版编译;在编辑器或许比播放器更多的加载中断;
++++这个函数需运行在Unity专业版;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ IEnumerator Start(){ AsyncOperation async = Application.LoadLevelAsync(“YanlzTestLevel01”); yield return async; Debug.Log(“立钻哥哥:Loading complete!”); } } //立钻哥哥:public class YanlzApplication{} |
++C3.13、OpenURL |
static void OpenURL(string url); |
++++在浏览器中打开url;
++++在编辑器或者独立播放器模式下,这将在缺省的浏览器中使用新页打开url;这将使浏览器位于前端;
++++但在网页中执行时,包含插件的页将被重定向到url;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void Start(){ Application.OpenURL(“http://www.i360game.com/”); } } //立钻哥哥:public class YanlzApplication{} |
++C3.14、Quit |
static void Quit(); |
++++退出应用程序;在编辑器或者Web播放器中退出被忽略;
++++在编辑器或网页播放器内退出无效;重要:在大多数情况下,iOS应用终止应由用户决定;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ void Update(){ if(Input.GetKey(“escape”)){ Application.Quit(); } } } //立钻哥哥:public class YanlzApplication{} |
++C3.15、RegisterLogCallback |
static void RegisterLogCallback(LogCallback handler); |
++++在一个日志信息上注册一个委托来被调用;
++++通过null来删除日志处理器;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ public string outPutStr = “”; public string stackStr = “”;
void OnEnable(){ Application.RegisterLogCallback(MyHandleLog); }
void OnDisable(){ Application.RegisterLogCallback(null); }
void MyHandleLog(string logString, string stackTrace, LogType type){ outPutstr = logString; stackStr = stackTrace }
} //立钻哥哥:public class YanlzApplication{} |
++C3.16、RegisterLogCallbackThreaded |
static void RegisterLogCallbackThreaded(LogCallback handler); |
++++在一个日志信息上注册一个委托来被调用;
++++这个函数和RegisterLogCallback唯一不同的是,这个函数将从不同的线程被调用;
++++注意:只有知道确实在做什么时才能使用这个函数,否则使用Application.RegisterLogCallback;
++C3.17、RequestUserAuthorization |
static AsyncOperation RequestUserAuthorization(UserAuthorization mode); |
++++在WebPlayer请求授权使用摄像头和麦克风;
++++处于安全原因(避免从网络播放器监视用户),需要用户明确允许在网络播放器使用这些功能;要这样做,需要调用Application.RequestUserAuthorization,显示对话框给用户,来等待用户确定完成来使用这个功能;使用Application.HasUserAuthorization来查询结果;
using UnityEngine; using System.Collections;
public class YanlzApplication : MonoBehaviour{ IEnumerator Start(){ yield return Application.RequestUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone);
if(Application.HasUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone)){ }else{ } } } //立钻哥哥:public class YanlzApplication{} |
++D4、立钻哥哥对Application类的拓展 |
++++【Unity开发基础】分类:https://blog.csdn.net/vrunsoftyanlz/category_7309057.html
++++【Linux系统编程】分类:https://blog.csdn.net/vrunsoftyanlz/category_9694767.html
++++【C++C铸就生存利器】分类:https://blog.csdn.net/vrunsoftyanlz/category_9325802.html
++++【人工智能AI2026】分类:https://blog.csdn.net/vrunsoftyanlz/category_9212024.html
++++【立钻哥哥CSDN空间】:https://blog.csdn.net/VRunSoftYanlz/
立钻哥哥推荐的拓展学习链接(Link_Url) |
++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz/
++++虚拟现实VR资讯: https://blog.csdn.net/VRunSoftYanlz/article/details/89165846
++++HTC_VIVE开发基础:https://blog.csdn.net/VRunSoftYanlz/article/details/81989970
++++Oculus杂谈:https://blog.csdn.net/VRunSoftYanlz/article/details/82469850
++++Oculus安装使用:https://blog.csdn.net/VRunSoftYanlz/article/details/82718982
++++Unity+SteamVR=>VR:https://blog.csdn.net/VRunSoftYanlz/article/details/88809370
++++Unity减少VR晕眩症:https://blog.csdn.net/VRunSoftYanlz/article/details/89115518
++++SteamVR简介:https://blog.csdn.net/VRunSoftYanlz/article/details/86484254
++++SteamVR脚本功能分析:https://blog.csdn.net/VRunSoftYanlz/article/details/86531480
++++SteamVR2.0开发指南:https://blog.csdn.net/VRunSoftYanlz/article/details/86618187
++++SteamVR2.2.0开发指南:https://blog.csdn.net/VRunSoftYanlz/article/details/88784527
++++SteamVR2.2.0快速入门:https://blog.csdn.net/VRunSoftYanlz/article/details/88833579
++++SteamVR2.2.0交互系统:https://blog.csdn.net/VRunSoftYanlz/article/details/89199778
++++SteamVR2.2.0传送机制:https://blog.csdn.net/VRunSoftYanlz/article/details/89390866
++++SteamVR2.2.0教程(一):https://blog.csdn.net/VRunSoftYanlz/article/details/89324067
++++SteamVR2.2.0教程(二):https://blog.csdn.net/VRunSoftYanlz/article/details/89894097
++++SteamVR_Skeleton_Poser:https://blog.csdn.net/VRunSoftYanlz/article/details/89931725
++++SteamVR实战之PMCore:https://blog.csdn.net/VRunSoftYanlz/article/details/89463658
++++SteamVR/Extras:https://blog.csdn.net/VRunSoftYanlz/article/details/86584108
++++SteamVR/Input:https://blog.csdn.net/VRunSoftYanlz/article/details/86601950
++++OpenXR简介:https://blog.csdn.net/VRunSoftYanlz/article/details/85726365
++++VRTK杂谈:https://blog.csdn.net/VRunSoftYanlz/article/details/82562993
++++VRTK快速入门(杂谈):https://blog.csdn.net/VRunSoftYanlz/article/details/82955267
++++VRTK官方示例(目录):https://blog.csdn.net/VRunSoftYanlz/article/details/82955410
++++VRTK代码结构(目录):https://blog.csdn.net/VRunSoftYanlz/article/details/82780085
++++VRTK(SceneResources):https://blog.csdn.net/VRunSoftYanlz/article/details/82795400
++++VRTK_ControllerEvents:https://blog.csdn.net/VRunSoftYanlz/article/details/83099512
++++VRTK_InteractTouch:https://blog.csdn.net/VRunSoftYanlz/article/details/83120220
++++虚拟现实行业应用:https://blog.csdn.net/VRunSoftYanlz/article/details/88360157
++++Steam平台上的VR:https://blog.csdn.net/VRunSoftYanlz/article/details/88960085
++++Steam平台热销VR:https://blog.csdn.net/VRunSoftYanlz/article/details/89007741
++++VR实验:以太网帧的构成:https://blog.csdn.net/VRunSoftYanlz/article/details/82598140
++++实验四:存储器扩展实验:https://blog.csdn.net/VRunSoftYanlz/article/details/87834434
++++FrameVR示例V0913:https://blog.csdn.net/VRunSoftYanlz/article/details/82808498
++++FrameVR示例V1003:https://blog.csdn.net/VRunSoftYanlz/article/details/83066516
++++SwitchMachineV1022:https://blog.csdn.net/VRunSoftYanlz/article/details/83280886
++++PlaySceneManagerV1022:https://blog.csdn.net/VRunSoftYanlz/article/details/83280886
++++Unity5.x用户手册:https://blog.csdn.net/VRunSoftYanlz/article/details/81712741
++++Unity面试题ABC:https://blog.csdn.net/vrunsoftyanlz/article/details/78630687
++++Unity面试题D:https://blog.csdn.net/VRunSoftYanlz/article/details/78630838
++++Unity面试题E:https://blog.csdn.net/vrunsoftyanlz/article/details/78630913
++++Unity面试题F:https://blog.csdn.net/VRunSoftYanlz/article/details/78630945
++++Cocos2dx面试题:https://blog.csdn.net/VRunSoftYanlz/article/details/78630967
++++禅道[zentao]:https://blog.csdn.net/VRunSoftYanlz/article/details/83964057
++++Lua快速入门篇(Xlua拓展):https://blog.csdn.net/VRunSoftYanlz/article/details/81173818
++++Lua快速入门篇(XLua教程):https://blog.csdn.net/VRunSoftYanlz/article/details/81141502
++++Lua快速入门篇(基础概述):https://blog.csdn.net/VRunSoftYanlz/article/details/81041359
++++框架知识点:https://blog.csdn.net/VRunSoftYanlz/article/details/80862879
++++游戏框架(UI框架夯实篇):https://blog.csdn.net/vrunsoftyanlz/article/details/80781140
++++游戏框架(初探篇):https://blog.csdn.net/VRunSoftYanlz/article/details/80630325
++++.Net框架设计:https://blog.csdn.net/VRunSoftYanlz/article/details/87401225
++++从零开始学架构:https://blog.csdn.net/VRunSoftYanlz/article/details/88095895
++++设计模式简单整理:https://blog.csdn.net/vrunsoftyanlz/article/details/79839641
++++专题:设计模式(精华篇):https://blog.csdn.net/VRunSoftYanlz/article/details/81322678
++++U3D小项目参考:https://blog.csdn.net/vrunsoftyanlz/article/details/80141811
++++Unity小游戏算法分析:https://blog.csdn.net/VRunSoftYanlz/article/details/87908365
++++Unity案例(Vehicle):https://blog.csdn.net/VRunSoftYanlz/article/details/82355876
++++UML类图:https://blog.csdn.net/vrunsoftyanlz/article/details/80289461
++++PowerDesigner简介:https://blog.csdn.net/VRunSoftYanlz/article/details/86500084
++++Unity知识点0001:https://blog.csdn.net/vrunsoftyanlz/article/details/80302012
++++Unity知识点0008:https://blog.csdn.net/VRunSoftYanlz/article/details/81153606
++++U3D_Shader编程(第一篇:快速入门篇):https://blog.csdn.net/vrunsoftyanlz/article/details/80372071
++++U3D_Shader编程(第二篇:基础夯实篇):https://blog.csdn.net/vrunsoftyanlz/article/details/80372628
++++Unity引擎基础:https://blog.csdn.net/vrunsoftyanlz/article/details/78881685
++++Unity面向组件开发:https://blog.csdn.net/vrunsoftyanlz/article/details/78881752
++++Unity物理系统:https://blog.csdn.net/vrunsoftyanlz/article/details/78881879
++++Unity2D平台开发:https://blog.csdn.net/vrunsoftyanlz/article/details/78882034
++++UGUI基础:https://blog.csdn.net/vrunsoftyanlz/article/details/78884693
++++UGUI进阶:https://blog.csdn.net/vrunsoftyanlz/article/details/78884882
++++UGUI综合:https://blog.csdn.net/vrunsoftyanlz/article/details/78885013
++++Unity动画系统基础:https://blog.csdn.net/vrunsoftyanlz/article/details/78886068
++++Unity动画系统进阶:https://blog.csdn.net/vrunsoftyanlz/article/details/78886198
++++Navigation导航系统:https://blog.csdn.net/vrunsoftyanlz/article/details/78886281
++++Unity特效渲染:https://blog.csdn.net/vrunsoftyanlz/article/details/78886403
++++Unity数据存储:https://blog.csdn.net/vrunsoftyanlz/article/details/79251273
++++Unity中Sqlite数据库:https://blog.csdn.net/vrunsoftyanlz/article/details/79254162
++++WWW类和协程:https://blog.csdn.net/vrunsoftyanlz/article/details/79254559
++++Unity网络:https://blog.csdn.net/vrunsoftyanlz/article/details/79254902
++++Unity资源加密:https://blog.csdn.net/VRunSoftYanlz/article/details/87644514
++++PhotonServer简介:https://blog.csdn.net/VRunSoftYanlz/article/details/86652770
++++编写Photon游戏服务器:https://blog.csdn.net/VRunSoftYanlz/article/details/86682935
++++C#事件:https://blog.csdn.net/vrunsoftyanlz/article/details/78631267
++++C#委托:https://blog.csdn.net/vrunsoftyanlz/article/details/78631183
++++C#集合:https://blog.csdn.net/vrunsoftyanlz/article/details/78631175
++++C#泛型:https://blog.csdn.net/vrunsoftyanlz/article/details/78631141
++++C#接口:https://blog.csdn.net/vrunsoftyanlz/article/details/78631122
++++C#静态类:https://blog.csdn.net/vrunsoftyanlz/article/details/78630979
++++C#中System.String类:https://blog.csdn.net/vrunsoftyanlz/article/details/78630945
++++C#数据类型:https://blog.csdn.net/vrunsoftyanlz/article/details/78630913
++++Unity3D默认的快捷键:https://blog.csdn.net/vrunsoftyanlz/article/details/78630838
++++游戏相关缩写:https://blog.csdn.net/vrunsoftyanlz/article/details/78630687
++++UnityAPI.Rigidbody刚体:https://blog.csdn.net/VRunSoftYanlz/article/details/81784053
++++UnityAPI.Material材质:https://blog.csdn.net/VRunSoftYanlz/article/details/81814303
++++UnityAPI.Android安卓:https://blog.csdn.net/VRunSoftYanlz/article/details/81843193
++++UnityAPI.AndroidJNI安卓JNI:https://blog.csdn.net/VRunSoftYanlz/article/details/81879345
++++UnityAPI.Transform变换:https://blog.csdn.net/VRunSoftYanlz/article/details/81916293
++++UnityAPI.WheelCollider轮碰撞器:https://blog.csdn.net/VRunSoftYanlz/article/details/82356217
++++UnityAPI.Resources资源:https://blog.csdn.net/VRunSoftYanlz/article/details/83155518
++++JSON数据结构:https://blog.csdn.net/VRunSoftYanlz/article/details/82026644
++++CocosStudio快速入门:https://blog.csdn.net/VRunSoftYanlz/article/details/82356839
++++Unity企业内训(目录):https://blog.csdn.net/VRunSoftYanlz/article/details/82634668
++++Unity企业内训(第1讲):https://blog.csdn.net/VRunSoftYanlz/article/details/82634733
++++Unity企业内训(第2讲):https://blog.csdn.net/VRunSoftYanlz/article/details/82861180
++++Unity企业内训(第3讲):https://blog.csdn.net/VRunSoftYanlz/article/details/82927699
++++Unity企业内训(第4讲):https://blog.csdn.net/VRunSoftYanlz/article/details/83479776
++++Unity企业内训(第5讲):https://blog.csdn.net/VRunSoftYanlz/article/details/83963811
++++Unity企业内训(第6讲):https://blog.csdn.net/VRunSoftYanlz/article/details/84207696
++++钻哥带您了解产品原型:https://blog.csdn.net/VRunSoftYanlz/article/details/87303828
++++插件
++++计算机组成原理(教材篇):https://blog.csdn.net/VRunSoftYanlz/article/details/82719129
++++5G接入:云计算和雾计算:https://blog.csdn.net/VRunSoftYanlz/article/details/88372718
++++云计算通俗讲义:https://blog.csdn.net/VRunSoftYanlz/article/details/88652803
++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz
--_--VRunSoft:lovezuanzuan--_--