From ef3e67645b848f52857e5bb6166d476dead4733b Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期二, 24 六月 2025 16:28:20 +0800 Subject: [PATCH] 0312 增加GM功能;封包接收去除旧代码;共用预制体改目录UIComp;共用UI颜色调整 --- Main/System/PhantasmPavilion/AvatarCell.cs | 46 ++++++++++++++++++++-------------------------- 1 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Main/System/PhantasmPavilion/AvatarCell.cs b/Main/System/PhantasmPavilion/AvatarCell.cs index f10574b..5c08b7c 100644 --- a/Main/System/PhantasmPavilion/AvatarCell.cs +++ b/Main/System/PhantasmPavilion/AvatarCell.cs @@ -1,10 +1,16 @@ using System.Collections.Generic; using UnityEngine; +//澶村儚妯″潡锛堟敮鎸佸抚鍔ㄧ敾鍜岀壒鏁堬級 public class AvatarCell : MonoBehaviour { public float scale = 1.0f; + private void Awake() + { + LoadPrefab(); + + } ImageEx m_BgImage; public ImageEx bgImage { @@ -12,7 +18,6 @@ { if (m_BgImage == null) { - LoadPrefab(); m_BgImage = this.GetComponent<ImageEx>("AvatarCell/Img_BG"); } return m_BgImage; @@ -26,7 +31,6 @@ { if (m_AvatarImage == null) { - LoadPrefab(); m_AvatarImage = this.GetComponent<ImageEx>("AvatarCell/Img_Avatar"); } return m_AvatarImage; @@ -40,7 +44,6 @@ { if (m_AvatarFrameImage == null) { - LoadPrefab(); m_AvatarFrameImage = this.GetComponent<ImageEx>("AvatarCell/Img_AvatarFrame"); } return m_AvatarFrameImage; @@ -54,7 +57,6 @@ { if (m_button == null) { - LoadPrefab(); m_button = this.GetComponent<ButtonEx>("AvatarCell/Img_AvatarFrame"); } return m_button; @@ -68,7 +70,6 @@ { if (m_AvatarUIFrame == null) { - LoadPrefab(); m_AvatarUIFrame = this.GetComponent<UIFrame>("AvatarCell/Img_Avatar"); } return m_AvatarUIFrame; @@ -82,7 +83,6 @@ { if (m_AvatarFrameUIFrame == null) { - LoadPrefab(); m_AvatarFrameUIFrame = this.GetComponent<UIFrame>("AvatarCell/Img_AvatarFrame"); } return m_AvatarFrameUIFrame; @@ -96,7 +96,6 @@ { if (m_AvatarUIEffect == null) { - LoadPrefab(); m_AvatarUIEffect = this.GetComponent<UIEffect>("AvatarCell/Img_Avatar"); } return m_AvatarUIEffect; @@ -110,7 +109,6 @@ { if (m_AvatarFrameUIEffect == null) { - LoadPrefab(); m_AvatarFrameUIEffect = this.GetComponent<UIEffect>("AvatarCell/Img_AvatarFrame"); } return m_AvatarFrameUIEffect; @@ -122,6 +120,8 @@ protected void LoadPrefab() { + if (prefab != null) + return; var tmp = transform.Find("AvatarCell"); if (tmp != null) @@ -129,25 +129,19 @@ prefab = tmp.gameObject; return; } - if (prefab == null) + prefab = UIUtility.CreateWidget("AvatarCell", "AvatarCell"); + + prefab.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); + prefab.transform.SetAsFirstSibling(); + + RectTransform prefabRect = prefab.GetComponent<RectTransform>(); + RectTransform parentRect = GetComponent<RectTransform>(); + if (prefabRect != null && parentRect != null) { - prefab = UIUtility.CreateWidget("AvatarCell", "AvatarCell"); - - if (prefab != null) - { - prefab.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one); - prefab.transform.SetAsFirstSibling(); - - RectTransform prefabRect = prefab.GetComponent<RectTransform>(); - RectTransform parentRect = GetComponent<RectTransform>(); - if (prefabRect != null && parentRect != null) - { - prefabRect.anchorMin = new Vector2(0.5f, 0.5f); - prefabRect.anchorMax = new Vector2(0.5f, 0.5f); - prefabRect.sizeDelta = new Vector2(parentRect.rect.width, parentRect.rect.height); - prefabRect.localScale = new Vector3(scale, scale, scale); - } - } + prefabRect.anchorMin = new Vector2(0.5f, 0.5f); + prefabRect.anchorMax = new Vector2(0.5f, 0.5f); + prefabRect.sizeDelta = new Vector2(parentRect.rect.width, parentRect.rect.height); + prefabRect.localScale = new Vector3(scale, scale, scale); } } -- Gitblit v1.8.0