using System; 
 | 
using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using Spine.Unity; 
 | 
using UnityEngine; 
 | 
using Spine; 
 | 
using UnityEngine.UI; 
 | 
using Cysharp.Threading.Tasks; 
 | 
  
 | 
//UI特效播放器,spine特效直接加载无需提前做预制体 
 | 
//UI特效大部分情况不会改变特效,无需销毁 
 | 
public class UIEffectPlayer : EffectPlayer 
 | 
{ 
 | 
  
 | 
  
 | 
    //spine里的第几个动画,!!closePMA参数无效暂时留着 
 | 
    public void Play(int index, bool showLog = true, bool closePMA = false) 
 | 
    { 
 | 
        playSpineAnimIndex = index; 
 | 
        PlayAsync(showLog, closePMA).Forget(); 
 | 
    } 
 | 
  
 | 
    //配置动画组数组索引 
 | 
    public void PlayByArrIndex(int index, bool showLog = true, bool closePMA = false) 
 | 
    { 
 | 
        var config = EffectConfig.Get(effectId); 
 | 
        playSpineAnimIndex = config.animIndex[index]; 
 | 
        PlayAsync(showLog, closePMA).Forget(); 
 | 
    } 
 | 
  
 | 
  
 | 
    //  创建后的特效会自动隐藏 需要手动调用Play才能播放 
 | 
    public static UIEffectPlayer CreateEffect(int effectId, Transform parent, bool createNewChild = false) 
 | 
    { 
 | 
        UIEffectPlayer effectPlayer = null; 
 | 
  
 | 
        if (createNewChild) 
 | 
        { 
 | 
            GameObject newGo = new GameObject("EffectPlayer_" + effectId); 
 | 
            newGo.transform.SetParent(parent, false); 
 | 
            effectPlayer = newGo.AddComponent<UIEffectPlayer>(); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            effectPlayer = parent.AddMissingComponent<UIEffectPlayer>(); 
 | 
            effectPlayer.effectId = effectId; 
 | 
        } 
 | 
        effectPlayer.SetActive(true); 
 | 
        return effectPlayer; 
 | 
    } 
 | 
  
 | 
  
 | 
    public void SetEnabled(bool isEnable) 
 | 
    {  
 | 
        if (spineComp == null) 
 | 
        { 
 | 
            return; 
 | 
        } 
 | 
        spineComp.enabled = isEnable; 
 | 
    } 
 | 
} 
 |