三国卡牌客户端基础资源仓库
hch
2026-06-29 c1c57a06cf3e3c937ac52e0e23ef2ddeae45de7b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Scripting;
 
 
[Preserve]
public class SkipUnityLogo
{
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
    private static void CancelSplashScreen()
    {
#if UNITY_IOS
        // iOS 16+ 上 Task.Run 在 BeforeSplashScreen 阶段可能无法及时调度,
        // 改用同步调用,确保 SplashScreen 被可靠停止。
        try
        {
            SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
        }
        catch (System.Exception)
        {
            // 如果 SplashScreen 已经不存在或已被禁用,忽略异常
        }
#else
        // Android 等平台:同步调用 SplashScreen.Stop 在 BeforeSplashScreen 阶段
        // 会导致主线程死锁(Player Loop 尚未完全初始化),必须通过 Task.Run 异步执行。
        System.Threading.Tasks.Task.Run(() =>
            SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate));
#endif
    }
 
#if !UNITY_IOS
    // Android 等平台上,BeforeSplashScreen 阶段的 Task.Run 可能因时序竞争
    // 而被引擎忽略,SubsystemRegistration 阶段引擎子系统已就绪,作为保底调用确保 Stop 生效。
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
    private static void CancelSplashScreenFallback()
    {
        try
        {
            SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
        }
        catch (System.Exception)
        {
            // 如果 SplashScreen 已在上面的回调中停止,这里的 Stop 会抛异常,忽略即可
        }
    }
#endif
}