赞
踩
Unity启动Logo让人非常不爽,因为展示unity logo非常拖沓, 延缓了打开游戏的时间,用0元购版本又怕收到律师函。
终于....刷github学习的时候意外发现一段有趣的代码,说是能跳过Unity Logo启动屏:
https://github.com/psygames/UnitySkipSplash/blob/main/SkipSplash.cs
翻了一下Unity API文档,Unity居然真的暴露了SplashScreen.Stop() 停止启动屏的API,跳过Unity Logo可是付费版用户的特权啊。居然这么草(tie)率(xin)的留出跳过logo的接口。简直是免费unity用户的福音啊!
只需要写个静态方法,使用[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]即在在显示启动画面之前调用这个静态方法,在静态方法中调用SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate)来立即停止启动屏。
enumeration
设置 RuntimeInitializeOnLoadMethod 类型。
另请参阅:RuntimeInitializeOnLoadMethodAttribute。
AfterSceneLoad | 在场景加载后。 |
BeforeSceneLoad | 在场景加载前。 |
AfterAssembliesLoaded | 加载完所有程序集并初始化预加载资源时的回调。 |
BeforeSplashScreen | 在显示启动画面之前。 |
SubsystemRegistration | 用于子系统注册的回调 |
使用方法:
1. 将下面脚本文件直接作为Runtime代码放到项目里(注意,不是Editor代码,是运行时代码)
2. 打包->运行。果然,Unity Logo消失了,瞬间进入游戏,快速干净清爽。非常好用,无需破解,官方支持,全平台适用。
- #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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。