【Unity】一步跳过Unity启动屏/Logo, 全平台适用,Unity官方API支持 | 您所在的位置:网站首页 › logo平台去 › 【Unity】一步跳过Unity启动屏/Logo, 全平台适用,Unity官方API支持 |
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)来立即停止启动屏。 RuntimeInitializeLoadTypeenumeration 描述设置 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 2018-2019 实验室设备网 版权所有 |