From ad3ac1661daaf4b445914f87009d3d88c990f040 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期二, 28 四月 2026 11:45:19 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into h5version

---
 Main/Component/UI/Effect/EffectPlayer.cs |  107 ++++++++++++++++++++++++++---------------------------
 1 files changed, 52 insertions(+), 55 deletions(-)

diff --git a/Main/Component/UI/Effect/EffectPlayer.cs b/Main/Component/UI/Effect/EffectPlayer.cs
index c506f18..19eb8a7 100644
--- a/Main/Component/UI/Effect/EffectPlayer.cs
+++ b/Main/Component/UI/Effect/EffectPlayer.cs
@@ -263,67 +263,64 @@
 
     protected async UniTask PlaySpineEffect(bool closePMA = false)
     {
-
-        // 浠庣壒鏁堥鍒朵綋姹犺幏鍙栫壒鏁�
-        if (spineComp == null)
-        { 
-            spineComp = gameObject.AddMissingComponent<SkeletonGraphic>();
-        }
-
-        if (spineComp.skeletonDataAsset == null || spineAnimationState == null)
+        try
         {
-            //LoadAsset 宸茬粡鏈夌紦瀛楽keletonDataAsset
-            spineComp.skeletonDataAsset = await ResManager.Instance.LoadAssetAsync<SkeletonDataAsset>("UIEffect/" + effectConfig.packageName, effectConfig.fxName);
-            //涓簍rue鏃朵細鏈夐儴鍒嗙壒鏁堜笉鏄剧ず 濡傛弧绾х粡楠屾潯锛涙敼鎴愪冀椹悗閮ㄥ垎鐗规晥姝e父锛岃繕鏈夐儴鍒嗕緷鐒惰鏀规璁剧疆
-            spineComp.MeshGenerator.settings.pmaVertexColors = !closePMA;   
-            spineComp.raycastTarget = false;
-            spineComp.Initialize(true);
-            // 妫�鏌ュ姩鐢绘槸鍚︽湁鐩稿姞妯″紡
-            // bool hasAdditiveBlend = CheckForAdditiveBlend(spineComp.Skeleton);
-            // if (hasAdditiveBlend)
-            // {
-            //    spineComp.material = ResManager.Instance.LoadAsset<Material>("UIEffect/" + effectConfig.packageName, effectConfig.fxName.Split('_')[0] + "_Material-Additive");
-            // }
-            // else
-            // {
-            //     spineComp.material = null;
-            // }
-            var material = await ResManager.Instance.LoadAssetAsync<Material>("Materials", "SkeletonGraphicDefault-Straight");
-            if (material != null)
-            {
-                spineComp.material = material;
-                #if UNITY_WEBGL && !UNITY_EDITOR
-                Debug.Log($"[SpineEffect][WebGL] effectId={effectConfig.id} fxName={effectConfig.fxName}" +
-                    $" mat={material.name} shader={material.shader.name}" +
-                    $" straightAlpha={material.IsKeywordEnabled("_STRAIGHT_ALPHA_INPUT")}" +
-                    $" canvasGroup={material.IsKeywordEnabled("_CANVAS_GROUP_COMPATIBLE")}" +
-                    $" pmaVert={spineComp.MeshGenerator.settings.pmaVertexColors}");
-                #endif
-            }
-            else
-            {
-                Debug.LogError("Failed to load material for Spine effect: " + effectConfig.fxName);
+            // 浠庣壒鏁堥鍒朵綋姹犺幏鍙栫壒鏁�
+            if (spineComp == null)
+            { 
+                spineComp = gameObject.AddMissingComponent<SkeletonGraphic>();
             }
 
-            spineAnimationState = spineComp.AnimationState;
-            spineAnimationState.TimeScale = speedRate;
-            spineAnimationState.Data.DefaultMix = 0f;
-            spineAnimationState.Complete -= OnSpineAnimationComplete;
-            spineAnimationState.Complete += OnSpineAnimationComplete;
+            if (spineComp.skeletonDataAsset == null || spineAnimationState == null)
+            {
+                //LoadAsset 宸茬粡鏈夌紦瀛楽keletonDataAsset锛涗娇鐢ㄥ紓姝PI鍏煎WebGL
+                spineComp.skeletonDataAsset = await ResManager.Instance.LoadAssetAsync<SkeletonDataAsset>("UIEffect/" + effectConfig.packageName, effectConfig.fxName);
+                if (this == null || spineComp == null) return;
+                //涓簍rue鏃朵細鏈夐儴鍒嗙壒鏁堜笉鏄剧ず 濡傛弧绾х粡楠屾潯锛涙敼鎴愪冀椹悗閮ㄥ垎鐗规晥姝e父锛岃繕鏈夐儴鍒嗕緷鐒惰鏀规璁剧疆
+                spineComp.MeshGenerator.settings.pmaVertexColors = !closePMA;   
+                spineComp.raycastTarget = false;
+                spineComp.Initialize(true);
+                // 妫�鏌ュ姩鐢绘槸鍚︽湁鐩稿姞妯″紡
+                // bool hasAdditiveBlend = CheckForAdditiveBlend(spineComp.Skeleton);
+                // if (hasAdditiveBlend)
+                // {
+                //    spineComp.material = ResManager.Instance.LoadAsset<Material>("UIEffect/" + effectConfig.packageName, effectConfig.fxName.Split('_')[0] + "_Material-Additive");
+                // }
+                // else
+                // {
+                //     spineComp.material = null;
+                // }
+                var material = await ResManager.Instance.LoadAssetAsync<Material>("Materials", "SkeletonGraphicDefault-Straight");
+                if (this == null || spineComp == null) return;
+                if (material != null)
+                {
+                    spineComp.material = material;
+#if UNITY_WEBGL && !UNITY_EDITOR
+                    Debug.Log($"[SpineEffect][WebGL] effectId={effectConfig.id} fxName={effectConfig.fxName}" +
+                        $" mat={material.name} shader={material.shader.name}" +
+                        $" straightAlpha={material.IsKeywordEnabled("_STRAIGHT_ALPHA_INPUT")}" +
+                        $" canvasGroup={material.IsKeywordEnabled("_CANVAS_GROUP_COMPATIBLE")}" +
+                        $" pmaVert={spineComp.MeshGenerator.settings.pmaVertexColors}");
+#endif
+                }
+
+                spineAnimationState = spineComp.AnimationState;
+                spineAnimationState.TimeScale = speedRate;
+                spineAnimationState.Data.DefaultMix = 0f;
+                spineAnimationState.Complete -= OnSpineAnimationComplete;
+                spineAnimationState.Complete += OnSpineAnimationComplete;
+            }
+
+            spineComp.enabled = true;
+            PlayerTheSpineAnim();
+            SoundPlayer.Instance.PlayUIAudioDelay(effectConfig.audio).Forget();
         }
-
-        spineComp.enabled = true;
-        PlayerTheSpineAnim();
-        SoundPlayer.Instance.PlayUIAudioDelay(effectConfig.audio).Forget();
-
-        #if UNITY_EDITOR
-        // 缂栬緫鍣ㄦā寮忎笅寮哄埗鍒锋柊鏉愯川鐞冿紝瑙e喅閮ㄥ垎鐗规晥涓嶆樉绀洪棶棰�
-        await UniTask.Delay(100);
-        if (spineComp != null && this != null && spineComp.material != null)
+        catch (Exception e)
         {
-            spineComp.material.shader = Shader.Find(spineComp.material.shader.name);
+            Debug.LogError(e);
         }
-        #endif
+
+        await UniTask.CompletedTask;
     }
 
         // 鎾斁鎸囧畾鍔ㄧ敾

--
Gitblit v1.8.0