[Unity实战]仅需25行代码 安卓/ios打包跳过Unity启动Logo动画...[新手开箱可用][全平台支持]

665 阅读1分钟

[Unity实战]仅需25行代码 安卓/ios打包跳过Unity启动Logo动画

参考文章

参考了我的朋友topgames的csdn文章
github中参考

接上一篇文章-unity隐私协议包通过审查

unity隐私协议

1.直接上代码:

SkipUnityLogo.cs

#if !UNITY_EDITOR
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Scripting;

/**
 * 跳过unity-logo
 */
[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

2.打包后使用效果展示:

请添加图片描述

3.源码地址:

测试apk
在这里插入图片描述源码