[Unity学习教程] unity个人版去logo

[复制链接]
查看940 | 回复0 | 2023-8-23 12:14:49 | 显示全部楼层 |阅读模式 来自 中国北京
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代码,是运行时代码)
  • 打包->运行。非常好用,无需破解,官方支持,全平台实用。
代码如下:
  1. #if !UNITY_EDITOR
  2. using UnityEngine;
  3. using UnityEngine.Rendering;
  4. [Preserve]
  5. public class SkipUnityLogo
  6. {
  7.     [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
  8.     private static void BeforeSplashScreen()
  9.     {
  10. #if UNITY_WEBGL
  11.         Application.focusChanged += Application_focusChanged;
  12. #else
  13.         System.Threading.Tasks.Task.Run(AsyncSkip);
  14. #endif
  15.     }
  16. #if UNITY_WEBGL
  17.     private static void Application_focusChanged(bool obj)
  18.     {
  19.         Application.focusChanged -= Application_focusChanged;
  20.         SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
  21.     }
  22. #else
  23.     private static void AsyncSkip()
  24.     {
  25.         SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
  26.     }
  27. #endif
  28. }
  29. #endif
复制代码
来源:https://blog.csdn.net/qq_37619255/article/details/128712294
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则