Unity启动Logo让人非常不爽,因为展示unity logo非常拖沓, 延缓了打开游戏的时间
翻了一下Unity API文档,Unity居然真的有SplashScreen.Stop() 停止启动屏的API
只需要写个静态方法,使用[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
即在在显示启动画面之前调用这个静态方法,在静态方法中调用SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate)
来立即停止启动屏。
具体使用方法
在任意不是Editor
的目录下新建代码脚本
#if !UNITY_EDITOR
using UnityEngine;
using UnityEngine.Rendering;
[UnityEngine.Scripting.Preserve]
public class SkipUnityLogo
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
private static void BeforeSplashScreen()
{
#if UNITY_WEBGL
Application.focusChanged += Application_focusChanged;
#else
System.Threading.Tasks.Task.Run(AsyncSkip);
#endif
}
#if UNITY_WEBGL
private static void Application_focusChanged(bool obj)
{
Application.focusChanged -= Application_focusChanged;
SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
}
#else
private static void AsyncSkip()
{
SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
}
#endif
}
#endif
打包->运行。发现Unity Logo果然消失了,瞬间进入游戏。
完结
如果你有其他更好的方法也欢迎评论分享出来,当然如果发现文章中出现了什么问题或者疑问的话,也欢迎评论私信告诉我哦
好了,我是向宇,https://xiangyu.blog.csdn.net/文章来源:https://uudwc.com/A/Jw3Jj
一位在小公司默默奋斗的开发者,出于兴趣爱好,于是开始自习unity。最近创建了一个新栏目【你问我答】,主要是想收集一下大家的问题,有时候一个问题可能几句话说不清楚,我就会以发布文章的形式来回答。 虽然有些问题我可能也不一定会,但是我会查阅各方资料,争取给出最好的建议,希望可以帮助更多想学编程的人,共勉~文章来源地址https://uudwc.com/A/Jw3Jj