From d67e53ae6cb3136b8e1836978b93a3021460ba29 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 25 十二月 2025 16:56:16 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts

---
 Main/Component/UI/Effect/UIEffectPlayer.cs |  137 ++++++---------------------------------------
 1 files changed, 19 insertions(+), 118 deletions(-)

diff --git a/Main/Component/UI/Effect/UIEffectPlayer.cs b/Main/Component/UI/Effect/UIEffectPlayer.cs
index 03669ac..5d70f0f 100644
--- a/Main/Component/UI/Effect/UIEffectPlayer.cs
+++ b/Main/Component/UI/Effect/UIEffectPlayer.cs
@@ -5,135 +5,27 @@
 using UnityEngine;
 using Spine;
 using UnityEngine.UI;
+using Cysharp.Threading.Tasks;
 
 //UI鐗规晥鎾斁鍣紝spine鐗规晥鐩存帴鍔犺浇鏃犻渶鎻愬墠鍋氶鍒朵綋
 //UI鐗规晥澶ч儴鍒嗘儏鍐典笉浼氭敼鍙樼壒鏁堬紝鏃犻渶閿�姣�
 public class UIEffectPlayer : EffectPlayer
 {
 
-    [Header("鏄惁寰幆鎾斁spine鐗规晥")]
-    public bool isPlaySpineLoop = false;
 
-    [Header("鏄惁鍦ㄦ樉绀烘椂鎾斁")]
-    public bool isPlayOnEnable = false;
-
-    protected override void OnEnable()
+    //spine閲岀殑绗嚑涓姩鐢伙紝锛侊紒closePMA鍙傛暟鏃犳晥鏆傛椂鐣欑潃
+    public void Play(int index, bool showLog = true, bool closePMA = false)
     {
-        if (isPlayOnEnable)
-        {
-            Play(false);
-        }
-        else if (spineComp != null)
-        {
-            //闅愯棌锛屼細鏈夐潤鎬佹樉绀洪棶棰�
-            spineComp.enabled = false;
-        }
+        playSpineAnimIndex = index;
+        PlayAsync(showLog, closePMA).Forget();
     }
 
-    public override void Play(bool showLog = true)
+    //閰嶇疆鍔ㄧ敾缁勬暟缁勭储寮�
+    public void PlayByArrIndex(int index, bool showLog = true, bool closePMA = false)
     {
-        if (!isInit)
-        {
-            InitComponent(showLog);
-            isInit = true;
-        }
-        else
-        {
-            //閬垮厤閲嶅鍒涘缓
-            if (!this.gameObject.activeSelf)
-            {
-                this.gameObject.SetActive(true);
-            }
-            return;
-        }
-
-        if (EffectMgr.IsNotShowBySetting(effectId))
-        {
-            return;
-        }
-
-        if (null != effectTarget)
-        {
-            if (pool != null)
-                pool.Release(effectTarget);
-            effectTarget = null;
-        }
-
-        if (!this.gameObject.activeSelf)
-        {
-            this.gameObject.SetActive(true);
-        }
-
-        // 鍔犺浇spine鐗规晥璧勬簮
-        if (effectConfig.isSpine != 0)
-        {
-            PlaySpineEffect();
-        }
-        else
-        { 
-            PlayerEffect(false);
-        }
-
-    }
-
-
-    protected override void PlaySpineEffect()
-    {
-        if (spineComp == null)
-        {
-            spineComp = gameObject.AddMissingComponent<SkeletonGraphic>();
-        }
-
-        if (spineComp.skeletonDataAsset == null)
-        {
-            //LoadAsset 宸茬粡鏈夌紦瀛楽keletonDataAsset
-            spineComp.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("UIEffect/" + effectConfig.packageName, effectConfig.fxName);
-            spineComp.raycastTarget = false;
-            spineComp.Initialize(true);
-            spineAnimationState = spineComp.AnimationState;
-            spineAnimationState.Data.DefaultMix = 0f;
-            spineAnimationState.Complete -= OnSpineAnimationComplete;
-            spineAnimationState.Complete += OnSpineAnimationComplete;
-        }
-
-        spineComp.enabled = true;
-        PlayerFistSpineAnim();
-    }
-
-
-    // 鎾斁绗竴涓姩鐢伙紙浣滀负榛樿鍔ㄧ敾锛�
-    void PlayerFistSpineAnim()
-    {
-        spineComp.enabled = true;
-        var skeletonData = spineComp.Skeleton.Data;
-        if (skeletonData.Animations.Count > 0)
-        {
-            string defaultAnimationName = skeletonData.Animations.Items[0].Name;
-            spineAnimationState.SetAnimation(0, defaultAnimationName, isPlaySpineLoop);
-        }
-        else
-        {
-            Debug.LogError("Spine 鏁版嵁涓病鏈夋壘鍒颁换浣曞姩鐢伙紒" + effectConfig.id);
-        }
-    }
-
-
-
-    //鍗曟鎾斁瀹屾瘯灏变細瑙﹀彂锛屽嵆浣挎槸寰幆
-    protected override void OnSpineAnimationComplete(Spine.TrackEntry trackEntry)
-    {
-        if (!isPlaySpineLoop)
-        {
-            spineComp.enabled = false;
-            if (isReleaseImmediately)
-            {
-                Stop();
-            }
-            else
-            {
-                onComplete?.Invoke();
-            }
-        }
+        var config = EffectConfig.Get(effectId);
+        playSpineAnimIndex = index < config.animIndex.Length ? config.animIndex[index] : 0;
+        PlayAsync(showLog, closePMA).Forget();
     }
 
 
@@ -157,4 +49,13 @@
         return effectPlayer;
     }
 
+
+	public void SetEnabled(bool isEnable)
+	{ 
+		if (spineComp == null)
+		{
+			return;
+		}
+		spineComp.enabled = isEnable;
+	}
 }

--
Gitblit v1.8.0