From b35cca26e2ee0e3a6b8a8c8d11c7253be4864609 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 18 七月 2025 14:55:30 +0800
Subject: [PATCH] 冲突解决
---
Main/System/Hero/UIHeroController.cs | 61 ++++++++++++++----------------
1 files changed, 28 insertions(+), 33 deletions(-)
diff --git a/Main/System/Hero/UIHeroController.cs b/Main/System/Hero/UIHeroController.cs
index 2891565..dde8706 100644
--- a/Main/System/Hero/UIHeroController.cs
+++ b/Main/System/Hero/UIHeroController.cs
@@ -1,40 +1,40 @@
+using System;
using Spine.Unity;
using UnityEngine;
-
+using UnityEngine.Events;
+using UnityEngine.EventSystems;
public class UIHeroController : MonoBehaviour
{
- public static UIHeroController Create(HeroSkinConfig skinCfg, Transform _parent = null)
+ public void Create(int _skinID, Action _onComplete = null)
{
- // GameObject battleGO = ResManager.Instance.LoadAsset<GameObject>("Hero/SpineRes", skinCfg == null ? "Hero_001" : skinCfg.SpineRes);
+ skinID = _skinID;
+ onComplete = _onComplete;
GameObject battleGO = ResManager.Instance.LoadAsset<GameObject>("Hero/SpineRes", "Hero_001");
GameObject instanceGO = null;
- if (_parent != null)
+ if (!transform.gameObject.activeSelf)
{
- instanceGO = GameObject.Instantiate(battleGO, _parent);
+ transform.SetActive(true);
}
- else
- {
- instanceGO = GameObject.Instantiate(battleGO);
- }
- UIHeroController heroController = instanceGO.AddMissingComponent<UIHeroController>();
- return heroController;
- }
-
- protected SkeletonGraphic skeletonGraphic;
-
- protected Spine.AnimationState spineAnimationState;
-
- private Spine.TrackEntry currentTrackEntry;
-
- void Awake()
- {
- skeletonGraphic = gameObject.GetComponentInChildren<SkeletonGraphic>(true);
+ instanceGO = GameObject.Instantiate(battleGO, transform);
+ skeletonGraphic = instanceGO.GetComponentInChildren<SkeletonGraphic>(true);
+ var skinConfig = HeroSkinConfig.Get(skinID);
+ skeletonGraphic.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinConfig.SpineRes + "_SkeletonData");
+ skeletonGraphic.Initialize(true);
spineAnimationState = skeletonGraphic.AnimationState;
PlayAnimation(MotionName.idle, true);
spineAnimationState.Complete += OnAnimationComplete;
}
+ private int skinID;
+ protected SkeletonGraphic skeletonGraphic;
+
+ protected Spine.AnimationState spineAnimationState;
+
+ private Spine.TrackEntry currentTrackEntry;
+ private Action onComplete;
+
+
void Destroy()
{
@@ -51,17 +51,12 @@
return currentTrackEntry;
}
- /// <summary>
- /// 鍔ㄧ敾瀹屾垚浜嬩欢澶勭悊
- /// </summary>
- protected virtual void OnAnimationComplete(Spine.TrackEntry trackEntry)
- {
- // string animation = trackEntry.Animation.Name;
- PlayAnimation(MotionName.idle, true);
+ /// <summary>
+ /// 鍔ㄧ敾瀹屾垚浜嬩欢澶勭悊
+ /// </summary>
+ protected virtual void OnAnimationComplete(Spine.TrackEntry trackEntry)
+ {
+ onComplete?.Invoke();
}
- protected void OnClick()
- {
- PlayAnimation(MotionName.attack);
- }
}
\ No newline at end of file
--
Gitblit v1.8.0