From eb27e5fd31f73b998a4bbd85511a31e40b8c61b7 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 21 十一月 2025 17:03:47 +0800
Subject: [PATCH] 0312 关闭游戏内日志
---
Main/System/Battle/BattleObject/BattleObjectFactory.cs | 54 ++++++++++++++++++++++++++++++++++++------------------
1 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/Main/System/Battle/BattleObject/BattleObjectFactory.cs b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
index 9bb60eb..82bbde4 100644
--- a/Main/System/Battle/BattleObject/BattleObjectFactory.cs
+++ b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System;
using UnityEngine;
@@ -9,8 +8,19 @@
// 鏈剰鏄鍦ㄨ繖閲屽仛姹犵殑鍐呭鐨� 浣嗘槸鎯充簡涓�涓� 鍒╃敤鏁堢巼鏈夌偣宸� 鏈�澶氬仛涓�涓嬬孩鑹叉柟鐨勭紦瀛� 钃濊壊鏂圭殑鍗虫椂鐢� 鍗虫椂鍒犻櫎 鎴栬�呯紦瀛樹笂涓�娆℃垬鏂楃殑灏辫
// private static int AutoIncrementID = 100000;
- private static float modelScaleRate => float.Parse(FuncConfigConfig.Get("BattleModelScale").Numerical1);
+ private static float m_modelScaleRate = 0f;
+ public static float modelScaleRate
+ {
+ get
+ {
+ if (m_modelScaleRate <= 0f)
+ {
+ m_modelScaleRate = float.Parse(FuncConfigConfig.Get("BattleModelScale").Numerical1);
+ }
+ return m_modelScaleRate;
+ }
+ }
// 杩欓噷鎶ラ敊浜嗘鏌ヤ竴涓�
public static BattleObject CreateBattleObject(BattleField _battleField, List<GameObject> posNodeList, TeamHero teamHero, BattleCamp _Camp)
{
@@ -23,20 +33,12 @@
GameObject battleGO = ResManager.Instance.LoadAsset<GameObject>("Hero/SpineRes", "Hero_001"/*skinCfg.SpineRes*/);
- if (battleGO == null)
- {
- Debug.LogError("BattleObjectFactory.CreateBattleObject: battleGO is null for " + teamHero.heroId);
- return null;
- }
-
- Debug.LogError("1 BattleObjectFactory.CreateBattleObject: Creating BattleObject for " + teamHero.ObjID + " at position " + teamHero.positionNum);
-
GameObject goParent = posNodeList[teamHero.positionNum];
BattleObject battleObject = new BattleObject(_battleField);
battleObject.ObjID = teamHero.ObjID;
GameObject realGO = GameObject.Instantiate(battleGO, goParent.transform);
- SkeletonGraphic skeletonGraphic = realGO.GetComponentInChildren<SkeletonGraphic>(true);
+ SkeletonAnimation skeletonAnimation = realGO.GetComponentInChildren<SkeletonAnimation>(true);
var skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinCfg.SpineRes);
if (skeletonDataAsset == null)
@@ -45,19 +47,35 @@
return null;
}
- Debug.LogError("2 BattleObjectFactory.CreateBattleObject: Creating BattleObject for " + teamHero.ObjID + " at position " + teamHero.positionNum);
-
-
float finalScaleRate = modelScaleRate * teamHero.modelScale;
- skeletonGraphic.skeletonDataAsset = skeletonDataAsset;
- skeletonGraphic.Initialize(true);
+ skeletonAnimation.initialSkinName = skinCfg.InitialSkinName;
+ skeletonAnimation.skeletonDataAsset = skeletonDataAsset;
+ skeletonAnimation.Initialize(true);
+
+ // 鍒濆鍖栧畬鎴愬悗璁剧疆鐨偆
+ if (!string.IsNullOrEmpty(skinCfg.InitialSkinName))
+ {
+ var skeleton = skeletonAnimation.Skeleton;
+ skeleton.SetSkin(skinCfg.InitialSkinName);
+ skeleton.SetSlotsToSetupPose();
+ skeletonAnimation.Update(0);
+ }
+
realGO.name = battleObject.ObjID.ToString();
realGO.transform.localScale = new Vector3(finalScaleRate, finalScaleRate, finalScaleRate);
+ RectTransform rectTrans = realGO.GetComponent<RectTransform>();
+ rectTrans.anchoredPosition = Vector2.zero;
battleObject.Init(realGO, teamHero, _Camp);
- Debug.LogError(realGO.name + " /3 BattleObjectFactory.CreateBattleObject: Creating BattleObject for " + teamHero.ObjID + " at position " + teamHero.positionNum);
-
+#if UNITY_EDITOR
+ BattleDebug.LogError(
+ "鍒濆鍖� 鏈鍔�" +
+ (battleObject.Camp == BattleCamp.Red ? "銆愮孩鏂广��" : "銆愯摑鏂广�� ") +
+ $"姝﹀皢: {battleObject.teamHero.name}\n" +
+ $"褰撳墠琛�閲�: {battleObject.teamHero.curHp} -> 鏈�澶ц閲弡battleObject.teamHero.maxHp}\n"
+ );
+#endif
return battleObject;
}
--
Gitblit v1.8.0