From 51e99e77ef79dccc0a5865588a9622943e8148a1 Mon Sep 17 00:00:00 2001 From: huqibin <762612145@qq.com> Date: Thu, 22 May 2025 10:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E9=AB=98=E7=B2=B1=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/UI_Panel/UI_GraphicRextualPanel.prefab | 38 ++++++++------- Assets/Scripts/HQB/SorghumController.cs | 4 +- .../UI/UI_Panel/UI_GraphicRextualPanel.cs | 48 +++++++++++++++---- Assets/Scripts/RawImageScript.cs | 1 + 4 files changed, 63 insertions(+), 28 deletions(-) diff --git a/Assets/Resources/UI/UI_Panel/UI_GraphicRextualPanel.prefab b/Assets/Resources/UI/UI_Panel/UI_GraphicRextualPanel.prefab index cfc5b2c..fd59f72 100644 --- a/Assets/Resources/UI/UI_Panel/UI_GraphicRextualPanel.prefab +++ b/Assets/Resources/UI/UI_Panel/UI_GraphicRextualPanel.prefab @@ -105,7 +105,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &3057948792150759128 RectTransform: m_ObjectHideFlags: 0 @@ -423,15 +423,15 @@ MonoBehaviour: m_Calls: [] m_text: New Text m_isRightToLeft: 0 - m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontAsset: {fileID: 11400000, guid: f8ef5cb2ab4d4da4093d3fe60f978c99, type: 2} + m_sharedMaterial: {fileID: -4829118149068189727, guid: f8ef5cb2ab4d4da4093d3fe60f978c99, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] m_fontColor32: serializedVersion: 2 - rgba: 4278190080 - m_fontColor: {r: 0, g: 0, b: 0, a: 1} + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} m_enableVertexGradient: 0 m_colorMode: 3 m_fontColorGradient: @@ -613,8 +613,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 194} - m_SizeDelta: {x: 200, y: 50} + m_AnchoredPosition: {x: 0, y: 36} + m_SizeDelta: {x: 200, y: 400} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &1947538143585023095 CanvasRenderer: @@ -644,17 +644,19 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: New Text + m_text: 'New Text + + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' m_isRightToLeft: 0 - m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontAsset: {fileID: 11400000, guid: 1c4004df1d65ff944b6e23e3af757df7, type: 2} + m_sharedMaterial: {fileID: 1751944718996602668, guid: 1c4004df1d65ff944b6e23e3af757df7, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] m_fontColor32: serializedVersion: 2 - rgba: 4278190080 - m_fontColor: {r: 0, g: 0, b: 0, a: 1} + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} m_enableVertexGradient: 0 m_colorMode: 3 m_fontColorGradient: @@ -671,15 +673,15 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 36 - m_fontSizeBase: 36 + m_fontSize: 20 + m_fontSizeBase: 20 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 0 - m_HorizontalAlignment: 2 - m_VerticalAlignment: 512 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 @@ -725,7 +727,7 @@ GameObject: - component: {fileID: 8605807043960739410} - component: {fileID: 8271235842251393859} m_Layer: 5 - m_Name: Image (1) + m_Name: Image_Left m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1003,7 +1005,7 @@ GameObject: - component: {fileID: 3100583911508305969} - component: {fileID: 54904237984238409} m_Layer: 5 - m_Name: Image (2) + m_Name: Image_Right m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/Assets/Scripts/HQB/SorghumController.cs b/Assets/Scripts/HQB/SorghumController.cs index 2860758..79f6aa0 100644 --- a/Assets/Scripts/HQB/SorghumController.cs +++ b/Assets/Scripts/HQB/SorghumController.cs @@ -47,13 +47,13 @@ public class SorghumController : PermanentTriggerBase { targetHD.SetActive(true); targetSD.SetActive(false); - GameManager.UIMgr.ShowPanel(); + GameManager.UIMgr.ShowPanel(E_UI_Layer.Mid, (p) => { p.Init(); }); } else { targetHD.SetActive(false); targetSD.SetActive(true); - GameManager.UIMgr.ShowPanel(); + GameManager.UIMgr.ShowPanel(E_UI_Layer.Mid, (p) => { p.Init(); }); } } } diff --git a/Assets/Scripts/Project/UI/UI_Panel/UI_GraphicRextualPanel.cs b/Assets/Scripts/Project/UI/UI_Panel/UI_GraphicRextualPanel.cs index dd57f7d..eef6ecc 100644 --- a/Assets/Scripts/Project/UI/UI_Panel/UI_GraphicRextualPanel.cs +++ b/Assets/Scripts/Project/UI/UI_Panel/UI_GraphicRextualPanel.cs @@ -5,18 +5,23 @@ using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; -public class allPlants +public class plantPart { - public class plantPart - { - public string partName; - public string partIntro; - } + public string partName; + public string partIntro; +} +public class allPlant +{ public string plantName; public List plantParts; } +public class plantsInfo +{ + public List allPlants; +} + public class UI_GraphicRextualPanel : BasePanel { public RawImage rawImage; @@ -27,11 +32,38 @@ public class UI_GraphicRextualPanel : BasePanel //ÄÚÈÝ public TextMeshProUGUI ContentTextMeshProUGUI; - public allPlants allPlants; + //public RawImageScript rawImageScript_Left; + //public RawImageScript rawImageScript_Right; + + public plantsInfo plantsInfo; public void Init() { - allPlants = JsonManager.Instance.LoadData("plantsInfo"); + plantsInfo = JsonManager.Instance.LoadData("plantsInfo"); + ToptextMeshProUGUI.text = ""; + ContentTextMeshProUGUI.text = ""; + } + + public void showPlantPartOnRawImage(GameObject partObj) + { + ToptextMeshProUGUI.text = ""; + ContentTextMeshProUGUI.text = ""; + + plantsInfo.allPlants.ForEach(plant => { + if (partObj.transform.parent.gameObject.name == plant.plantName) + { + string title = plant.plantName + ":"; + plant.plantParts.ForEach(part => + { + if (partObj.name == part.partName) + { + ToptextMeshProUGUI.text = (title += part.partName); + ContentTextMeshProUGUI.text = part.partIntro; + return; + } + }); + } + }); } protected override void Awake() diff --git a/Assets/Scripts/RawImageScript.cs b/Assets/Scripts/RawImageScript.cs index 71ccf42..3610aba 100644 --- a/Assets/Scripts/RawImageScript.cs +++ b/Assets/Scripts/RawImageScript.cs @@ -66,6 +66,7 @@ public class RawImageScript : MonoBehaviour, IPointerEnterHandler, IPointerExitH if (_highlight != null) { _highlight.SetHighlighted(true); + rextualPanel.showPlantPartOnRawImage(hit.collider.gameObject); } } else