From 5a4e34c8a85737c0fa5b5775122da31155cbaef3 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 09 二月 2026 14:46:01 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts
---
Main/Component/UI/Effect/EffectPlayer.cs | 75 ++++++++++++++++++++++++++-----------
1 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/Main/Component/UI/Effect/EffectPlayer.cs b/Main/Component/UI/Effect/EffectPlayer.cs
index 22b7ab3..e12dbe3 100644
--- a/Main/Component/UI/Effect/EffectPlayer.cs
+++ b/Main/Component/UI/Effect/EffectPlayer.cs
@@ -24,6 +24,7 @@
{
if (value != m_EffectID)
{
+ Stop();
isInit = false;
m_EffectID = value;
}
@@ -34,7 +35,7 @@
public EffectConfig effectConfig;
- public float speedRate = 1f;
+ public float speedRate = 1f; //鍒濆鍖栫殑鏃跺�欑敤 淇敼浣跨敤SetSpeed
[Header("鏄惁寰幆鎾斁spine鐗规晥")]
public bool isPlaySpineLoop = false;
@@ -60,7 +61,11 @@
protected EffectPenetrationBlocker blocker = null;
protected bool isInit = false;
- protected bool isPlaying = false;
+ public bool isPlaying
+ {
+ get;
+ protected set;
+ }
protected List<ParticleSystem> particleList = new List<ParticleSystem>();
@@ -77,8 +82,12 @@
protected virtual void OnEnable()
{
-
- if (isPlayOnEnable)
+
+ if (isPlayOnEnable && playDelayTime != 0)
+ {
+ PlayAsync(false).Forget();
+ }
+ else if (isPlayOnEnable)
{
Play(false);
}
@@ -167,7 +176,7 @@
Clear();
}
- public virtual void Play(bool showLog = true)
+ public virtual void Play(bool showLog = true, bool closePMA = false)
{
isPlaying = true;
if (!isInit)
@@ -186,15 +195,17 @@
//闃茶寖effeid 涓�0
if (effectConfig != null && effectConfig.isSpine != 0)
{
- PlaySpineEffect();
+ PlaySpineEffect(closePMA);
}
return;
}
+ if (effectConfig == null)
+ return;
if (EffectMgr.IsNotShowBySetting(effectId))
- {
- return;
- }
+ {
+ return;
+ }
if (null != effectTarget)
{
@@ -211,14 +222,14 @@
// 鍔犺浇spine鐗规晥璧勬簮
if (effectConfig.isSpine != 0)
{
- PlaySpineEffect();
+ PlaySpineEffect(closePMA);
}
else
{
PlayerEffect();
}
- SoundPlayer.Instance.PlayUIAudio(effectConfig.audio);
+
}
@@ -238,9 +249,19 @@
// return;
// }
+ //瓒婂ぇ瓒婂揩
+ public void SetSpeed(float speed)
+ {
+ speedRate = speed;
+ if (spineAnimationState == null)
+ {
+ Debug.LogError("spineAnimationState is null 鍙互鍏堣皟鐢╬lay");
+ return;
+ }
+ spineAnimationState.TimeScale = speed;
+ }
-
- protected void PlaySpineEffect()
+ protected void PlaySpineEffect(bool closePMA = false)
{
// 浠庣壒鏁堥鍒朵綋姹犺幏鍙栫壒鏁�
@@ -253,10 +274,10 @@
{
//LoadAsset 宸茬粡鏈夌紦瀛楽keletonDataAsset
spineComp.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("UIEffect/" + effectConfig.packageName, effectConfig.fxName);
-
+ //涓簍rue鏃朵細鏈夐儴鍒嗙壒鏁堜笉鏄剧ず 濡傛弧绾х粡楠屾潯锛涙敼鎴愪冀椹悗閮ㄥ垎鐗规晥姝e父锛岃繕鏈夐儴鍒嗕緷鐒惰鏀规璁剧疆
+ spineComp.MeshGenerator.settings.pmaVertexColors = !closePMA;
spineComp.raycastTarget = false;
spineComp.Initialize(true);
- spineComp.timeScale = speedRate;
// 妫�鏌ュ姩鐢绘槸鍚︽湁鐩稿姞妯″紡
// bool hasAdditiveBlend = CheckForAdditiveBlend(spineComp.Skeleton);
// if (hasAdditiveBlend)
@@ -270,6 +291,7 @@
spineComp.material = ResManager.Instance.LoadAsset<Material>("Materials", "SkeletonGraphicDefault-Straight");
spineAnimationState = spineComp.AnimationState;
+ spineAnimationState.TimeScale = speedRate;
spineAnimationState.Data.DefaultMix = 0f;
spineAnimationState.Complete -= OnSpineAnimationComplete;
spineAnimationState.Complete += OnSpineAnimationComplete;
@@ -277,18 +299,23 @@
spineComp.enabled = true;
PlayerTheSpineAnim();
+ SoundPlayer.Instance.PlayUIAudioDelay(effectConfig.audio).Forget();
}
// 鎾斁鎸囧畾鍔ㄧ敾
void PlayerTheSpineAnim()
{
-
spineComp.enabled = true;
var skeletonData = spineComp.Skeleton.Data;
if (skeletonData.Animations.Count > 0)
{
//鎸夐厤缃垨鑰呴粯璁ょ涓�涓�
int defaultAnimIndex = Math.Max(0, effectConfig.animIndex.Length == 0 ? 0 : effectConfig.animIndex[0]);
+ if (playSpineAnimIndex >= skeletonData.Animations.Count)
+ {
+ playSpineAnimIndex = -1;
+ Debug.LogError("鐗规晥锛�" + effectConfig.id + " 绱㈠紩瓒呭嚭鎾斁榛樿鍔ㄧ敾銆� error锛�" + playSpineAnimIndex);
+ }
string defaultAnimationName = skeletonData.Animations.Items[playSpineAnimIndex == -1 ? defaultAnimIndex : playSpineAnimIndex].Name;
spineAnimationState.SetAnimation(0, defaultAnimationName, isPlaySpineLoop);
}
@@ -335,7 +362,7 @@
}
// 浠庣壒鏁堥鍒朵綋姹犺幏鍙栫壒鏁�
- pool = GameObjectPoolManager.Instance.RequestPool(effectPrefab);
+ pool = GameObjectPoolManager.Instance.GetPool(effectPrefab);
effectTarget = pool.Request();
// 璁剧疆鐖惰妭鐐瑰拰浣嶇疆
effectTarget.transform.SetParent(transform);
@@ -363,14 +390,15 @@
{
blocker.SetParentCanvas(canvas);
}
+ SoundPlayer.Instance.PlayUIAudioDelay(effectConfig.audio).Forget();
}
- public async UniTask PlayAsync(bool showLog = true)
+ public async UniTask PlayAsync(bool showLog = true, bool closePMA = false)
{
await UniTask.Delay(playDelayTime);
try
{
- Play(showLog);
+ Play(showLog, closePMA);
}
catch (Exception e)
{
@@ -404,10 +432,11 @@
spineComp.enabled = false;
isPlaying = false;
onComplete?.Invoke();
- if (isReleaseImmediately)
- {
- Release();
- }
+ // TODO 浼氭姤閿欐殏鏃舵敞閲�
+ // if (isReleaseImmediately)
+ // {
+ // Release();
+ // }
}
}
--
Gitblit v1.8.0