From dc7922d80c1d133b6261b8af1d521567d2c0a35d Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 30 十月 2025 16:51:39 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts
---
Main/System/Hero/UIHeroController.cs | 72 +++++++++++++++++++++++++++--------
1 files changed, 55 insertions(+), 17 deletions(-)
diff --git a/Main/System/Hero/UIHeroController.cs b/Main/System/Hero/UIHeroController.cs
index 852fcef..2ad5cd7 100644
--- a/Main/System/Hero/UIHeroController.cs
+++ b/Main/System/Hero/UIHeroController.cs
@@ -17,7 +17,7 @@
public void Create(int _skinID, float scale = 0.8f, Action _onComplete = null, string motionName = "idle", bool isLh = false)
{
if (skinID == _skinID)
- {
+ {
//閬垮厤閲嶅鍒涘缓
return;
}
@@ -49,35 +49,36 @@
lhImg.SetTexture2DPNG(skinConfig.Tachie);
lhImg.SetNativeSize();
if (skeletonGraphic != null)
- {
+ {
skeletonGraphic.enabled = false;
}
lhImg.enabled = true;
+ lhImg.raycastTarget = false;
return;
}
else
{
if (skeletonGraphic != null)
- {
+ {
skeletonGraphic.enabled = true;
}
lhImg.enabled = false;
}
}
else
- {
+ {
this.transform.localScale = Vector3.one * scale;
}
onComplete = _onComplete;
pool = GameObjectPoolManager.Instance.RequestPool(UILoader.LoadPrefab("UIHero"));
-
+
if (!transform.gameObject.activeSelf)
{
transform.SetActive(true);
}
if (instanceGO == null)
- {
+ {
instanceGO = pool.Request();
instanceGO.transform.SetParent(transform);
//transform 鐨凱ivot Y鏄�0锛岃instanceGO 灞呬腑
@@ -109,7 +110,7 @@
return;
}
skeletonGraphic.Initialize(true);
-
+
spineAnimationState = skeletonGraphic.AnimationState;
spineAnimationState.Data.DefaultMix = 0f;
if (motionName == "")
@@ -124,24 +125,32 @@
protected void OnDestroy()
{
- if (spineAnimationState != null)
- {
- spineAnimationState.Complete -= OnAnimationComplete;
- }
+ if (spineAnimationState != null)
+ {
+ spineAnimationState.Complete -= OnAnimationComplete;
+ }
if (pool != null)
pool.Release(instanceGO);
skeletonGraphic = null;
pool = null;
}
+ /// <summary>
+ /// 鎾斁 Spine 鍔ㄧ敾
+ /// </summary>
+ /// <param name="motionName">鍔ㄤ綔鍚�</param>
+ /// <param name="loop">寰幆</param>
+ /// <param name="replay">濡傛灉鐩稿悓鍔ㄤ綔鏄惁鍐嶆閲嶆挱锛屾瘮濡傝窇姝ラ噸鎾氨浼氳烦甯т笉椤烘粦</param>
+ public virtual void PlayAnimation(string motionName, bool loop = false, bool replay=true)
+ {
+ if (spineAnimationState == null) return;
- public virtual void PlayAnimation(string motionName, bool loop = false)
- {
- if (spineAnimationState == null) return;
+ if (GetCurrentAnimationName() == motionName && !replay)
+ return;
// 鐩存帴浣跨敤 ToString() 鑰屼笉鏄皟鐢� GetAnimationName
- spineAnimationState.SetAnimation(0, motionName.ToString(), loop);
- }
+ spineAnimationState.SetAnimation(0, motionName.ToString(), loop);
+ }
// 鎾斁绗竴涓姩鐢伙紙浣滀负榛樿鍔ㄧ敾锛�
string GetFistSpineAnim()
@@ -156,7 +165,22 @@
Debug.LogError("Spine 鏁版嵁涓病鏈夋壘鍒颁换浣曞姩鐢伙紒姝﹀皢鐨偆锛�" + skinID);
}
return "";
- }
+ }
+
+ /// <summary>
+ /// 鑾峰彇褰撳墠姝e湪鎾斁鐨� Spine 鍔ㄧ敾鍚嶇О
+ /// </summary>
+ /// <returns>褰撳墠鍔ㄧ敾鍚嶇О锛屽鏋滄病鏈夊姩鐢诲垯杩斿洖绌哄瓧绗︿覆</returns>
+ public string GetCurrentAnimationName()
+ {
+ if (spineAnimationState == null || spineAnimationState.GetCurrent(0) == null)
+ {
+ return string.Empty;
+ }
+ return spineAnimationState.GetCurrent(0).Animation.Name;
+ }
+
+
/// <summary>
/// 鍔ㄧ敾瀹屾垚浜嬩欢澶勭悊
@@ -166,4 +190,18 @@
onComplete?.Invoke();
}
+ //瓒婂ぇ瓒婂揩
+ public void SetSpeed(float speed)
+ {
+ spineAnimationState.TimeScale = speed;
+ }
+
+ public void SetEnabled(bool isEnable)
+ {
+ if (skeletonGraphic == null)
+ {
+ return;
+ }
+ skeletonGraphic.enabled = isEnable;
+ }
}
\ No newline at end of file
--
Gitblit v1.8.0