三国卡牌客户端基础资源仓库
yyl
3 天以前 952470d53334cea122c2ec74a0f204d8ddb6a035
Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_client
3个文件已修改
58 ■■■■■ 已修改文件
Assets/Editor/Logo/sghy/Icon.png 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Tool/ClientPackage.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Launch/SkipUnityLogo/Script/SkipUnityLogo.cs 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Logo/sghy/Icon.png

Assets/Editor/Tool/ClientPackage.cs
@@ -1055,6 +1055,26 @@
            PlayerSettings.Android.splashScreenScale = AndroidSplashScreenScale.ScaleToFill;
        }
        else if (buildTarget == BuildTargetGroup.iOS)
        {
            var projectSettings = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]);
            // 使用 Image and background (relative) 模式
            projectSettings.FindProperty("iOSLaunchScreenType").intValue = 1;
            // 设置 iPhone 竖屏启动图
            projectSettings.FindProperty("iOSLaunchScreenPortrait").objectReferenceValue = splashImage.texture;
            // 设置 iPhone 横屏启动图
            projectSettings.FindProperty("iOSLaunchScreenLandscape").objectReferenceValue = splashImage.texture;
            // iPad 也使用独立的 Image and background 模式(必须设为 1 才能触发 iPad Storyboard 和图片的重新生成)
            projectSettings.FindProperty("iOSLaunchScreeniPadType").intValue = 1;
            // 设置 iPad 启动图
            projectSettings.FindProperty("iOSLaunchScreeniPadImage").objectReferenceValue = splashImage.texture;
            // 关键修复:Unity 闪屏背景色设为黑色,与 LaunchScreen 黑色背景一致
            // iOS 16 上 SkipUnityLogo 的 Task.Run 可能无法及时执行 SplashScreen.Stop(),
            // Unity 闪屏会短暂露出背景色。设为黑色后即便露出也跟 LaunchScreen 无缝衔接。
            projectSettings.FindProperty("m_SplashScreenBackgroundColor").boxedValue = Color.black;
            projectSettings.ApplyModifiedProperties();
            Debug.Log($"[ClientPackage] iOS LaunchScreen 已设置,version: {_versionName}");
        }
    }
    public static void SetCreateRoleAnimation()
Assets/Launch/SkipUnityLogo/Script/SkipUnityLogo.cs
@@ -1,6 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Scripting;
@@ -12,6 +9,39 @@
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
    private static void CancelSplashScreen()
    {
        Task.Run(()=>SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate));
#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
}