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 用于子系统注册的回调
使用方法:文章来源:https://www.toymoban.com/news/detail-817018.html
- 将下面脚本文件直接作为Runtime代码放到项目里(注意,不是Editor代码,是运行时代码)
- 打包->运行。非常好用,无需破解,官方支持,全平台适用。
代码如下:文章来源地址https://www.toymoban.com/news/detail-817018.html
#if !UNITY_EDITOR
using UnityEngine;
using UnityEngine.Rendering;
[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的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!