Unity加载设置:Application.backgroundLoadingPriority

Application.backgroundLoadingPriority:

这是Application类的一个个静态属性,可以控制后台加载线程的优先级,从而控制异步加载资源所需的时间,以及后台加载时对游戏性能的影响。

适用API:

加载对象(Resources.LoadAsyncAssetBundle.LoadAssetAsync,AssetBundle.LoadAllAssetAsync),场景(Application.LoadLevelAsync,Application.LoadLevelAdditiveAsync)的异步加载函数在单独的后台加载线程上进行数据读取和反现实化,并在主线程上进行对象集成。

根据backgroundLoadingPriority 值限制了主线程上的集成时间:
- ThreadPriority.Low - 2ms;
- ThreadPriority.BelowNormal - 4ms;
- ThreadPriority.Normal - 10ms;
- ThreadPriority.High - 50ms.

这是异步操作可以在主线程的单帧花费最长时间。

单帧花费时间越多,可加载的数据越多,因此帧率将有所下降,较为影响游戏性能,但可减少加载资源的时间,能更快的进入游戏!

反之,单帧花费时间越少,可加载的数据越少,对游戏的游戏性能影响较小,可在游戏进行时有很好的后台加载。

// Load as much data as possible, as a result frame rate will drop.
// Good for fast loading when showing progress bars.
//装载尽可能多的数据传输速率,因此帧将下降。 
//加载时显示出良好的快速进度条。
Application.backgroundLoadingPriority = ThreadPriority.High ;
 
// Load data very slowly and try not to affect performance of the game.
// Good for loading in the background while the game is playing.
//加载数据速度非常慢,尽量不影响游戏性能的。 
//在游戏进行时有很好的后台加载。
Application.backgroundLoadingPriority = ThreadPriority.Low ;

猜你喜欢

转载自blog.csdn.net/m1234567q/article/details/111242345