From ad0b0d64fcde485d5e906e8334835ebede4f0256 Mon Sep 17 00:00:00 2001 From: GL <2365963573@qq.com> Date: Tue, 24 Dec 2024 18:02:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=82=E7=BA=A7=EF=BC=8C=E6=9C=89=E7=82=B9?= =?UTF-8?q?=E8=AF=B4=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Prefabs/charatar/enemy/wood_min.prefab | 17 +++++++++++++++- meng_yao/Assets/script/A_Fight/SpawnPool.cs | 20 +++++++++---------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/meng_yao/Assets/Prefabs/charatar/enemy/wood_min.prefab b/meng_yao/Assets/Prefabs/charatar/enemy/wood_min.prefab index a02369e1e..d05b2a7ec 100644 --- a/meng_yao/Assets/Prefabs/charatar/enemy/wood_min.prefab +++ b/meng_yao/Assets/Prefabs/charatar/enemy/wood_min.prefab @@ -311,6 +311,7 @@ MonoBehaviour: - {fileID: 0} - {fileID: 0} moveSpeed: 1 + speedFactor: 1 obj: {fileID: 4703411402842800732} --- !u!114 &4703411402755586929 MonoBehaviour: @@ -327,6 +328,7 @@ MonoBehaviour: retbutton: {fileID: 0} ClosureObj: {fileID: 0} id: 0 + Name: camp: 1 hp: 100 dieIndex: 1 @@ -336,7 +338,18 @@ MonoBehaviour: _Canvas: {fileID: 4205844203331515742} spriteRenderers: {fileID: 4703411402842800734} HurtDirectin: 0 + Quality: + Elements: + Info: + SkillId: + AttackType: + AttackActionType: + AttackCD: 0 + CritRate: 0 + CriticalHitRateBonus: 0 gold: 10 + MaxAttack: 10 + MinAttack: 10 physicalArmor: 10 magicArmor: 5 Navigation: {fileID: 4703411402755586928} @@ -495,6 +508,8 @@ MonoBehaviour: role: {fileID: 4703411402755586929} panelPrefab: {fileID: 103310189314411435, guid: 750dbc96a3815eb4c85c7f89c206a43f, type: 3} attackRange: {fileID: 0} + isShowPanel: 0 + instantiatedPanel: {fileID: 0} --- !u!1 &4703411402469012869 GameObject: m_ObjectHideFlags: 0 @@ -599,7 +614,7 @@ SpriteRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: 97cc9a8eaafc8d24a849cc7f6ceb3b13, type: 3} + m_Sprite: {fileID: 21300000, guid: 5a21d33cca7048a46aed91d4e3e32ec3, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 diff --git a/meng_yao/Assets/script/A_Fight/SpawnPool.cs b/meng_yao/Assets/script/A_Fight/SpawnPool.cs index c40dccf5d..fce21318d 100644 --- a/meng_yao/Assets/script/A_Fight/SpawnPool.cs +++ b/meng_yao/Assets/script/A_Fight/SpawnPool.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Rendering; public class ObJPool { @@ -87,17 +88,16 @@ public class SpawnPool : Base } public void UpdateNodeList() { - // 获取所有带有 SpriteRenderer 组件的子物体 + // 获取所有带有 SortingGroup 组件的物体 List gameObjectsList = new List(); foreach (GameObject go in EnemyPool.SurvivalPool) { - // 获取所有子物体中具有 SpriteRenderer 组件的物体 - SpriteRenderer renderer = go.GetComponentInChildren(); - if (renderer != null) + // 获取该物体上的 SortingGroup 组件 + SortingGroup sortingGroup = go.GetComponent(); + if (sortingGroup != null) { // 添加到列表中 - //Debug.Log("排序添加--------"); gameObjectsList.Add(go); } } @@ -105,16 +105,14 @@ public class SpawnPool : Base // 按照 y 轴排序 gameObjectsList.Sort((a, b) => a.transform.position.y.CompareTo(b.transform.position.y)); - // 设置 sortingOrder + // 设置 SortingGroup 的 sortingOrder for (int i = 0; i < gameObjectsList.Count; i++) { - SpriteRenderer renderer = gameObjectsList[i].GetComponentInChildren(); - if (renderer != null) + SortingGroup sortingGroup = gameObjectsList[i].GetComponent(); + if (sortingGroup != null) { // 设置 sortingOrder 来决定显示的层级 - - renderer.sortingOrder = gameObjectsList.Count-i; - //Debug.Log("排序--------"); + sortingGroup.sortingOrder = gameObjectsList.Count - i; } } }