github上一段代码,跳过Unity Logo启动屏:
github链接: https://github.com/psygames/UnitySkipSplash/blob/main/SkipSplash.cs
Unity API文档,Unity暴露了SplashScreen.Stop() 停止启动屏的API
只需要写个静态方法,使用[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]即在在显示启动画面之前调用这个静态方法,在静态方法中调用SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate)来立即停止启动屏。
RuntimeInitializeLoadType变量
AfterSceneLoad 在场景加载后。
BeforeSceneLoad 在场景加载前。
AfterAssembliesLoaded 加载完所有程序集并初始化预加载资源时的回调。
BeforeSplashScreen 在显示启动画面之前。
SubsystemRegistration 用于子系统注册的回调
使用方法:
- 将下面脚本文件直接作为Runtime代码放到项目里(注意,不是Editor代码,是运行时代码)
- 打包->运行。非常好用,无需破解,官方支持,全平台适用。
#if !UNITY_EDITOR
using UnityEngine;
using UnityEngine.Rendering;
using 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
原链接: https://blog.csdn.net/qq_37619255/article/details/128712294
标签:BeforeSplashScreen,focusChanged,Stop,Application,Unity,屏页,跳过,SplashScreen From: https://www.cnblogs.com/su-make/p/18373600