From faeb18b95ed595315a48b1b53c505808adbfe57b Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Fri, 7 Mar 2025 15:18:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0texttip=E7=9A=84=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E9=80=8F=E6=98=8E=E5=BA=A6=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Art/UIPrefab/UITextTip.prefab | 22 ++++++++++++++++++++-- Assets/Scripts/Actions/TextTipAction.cs | 9 +++++++++ Assets/Scripts/UI/UITextTip.Designer.cs | 5 ++++- Assets/Scripts/UI/UITextTip.cs | 4 ++++ Assets/Scripts/Xml/XmlParser.cs | 5 +++++ Doc/Xml配置文档.xml | 6 ++++-- 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/Assets/Art/UIPrefab/UITextTip.prefab b/Assets/Art/UIPrefab/UITextTip.prefab index 3d8f00a0..14d14538 100644 --- a/Assets/Art/UIPrefab/UITextTip.prefab +++ b/Assets/Art/UIPrefab/UITextTip.prefab @@ -460,6 +460,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5ed9b43aa6da2fd49af65b4ab0b85fc2, type: 3} m_Name: m_EditorClassIdentifier: + Mask: {fileID: 1168405647267019539} Title: {fileID: 3613689092755446169} Des: {fileID: 5150898215778594440} BtnContent: {fileID: 8598386973860236803} @@ -626,6 +627,7 @@ GameObject: - component: {fileID: 7621766697555444520} - component: {fileID: 5831602004918006429} - component: {fileID: 1168405647267019539} + - component: {fileID: 6844797422068731548} m_Layer: 5 m_Name: Mask m_TagString: Untagged @@ -669,13 +671,13 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4085354983340029108} - m_Enabled: 0 + m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0, g: 0, b: 0, a: 0.5019608} + m_Color: {r: 0, g: 0, b: 0, a: 0} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -692,6 +694,22 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!114 &6844797422068731548 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4085354983340029108} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0d51f3a7c41ab0346b49ae50d456bece, type: 3} + m_Name: + m_EditorClassIdentifier: + MarkType: 0 + CustomComponentName: + CustomComment: + mComponentName: UnityEngine.UI.Image --- !u!1 &4287411951672065129 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Actions/TextTipAction.cs b/Assets/Scripts/Actions/TextTipAction.cs index 4fb06b14..2ed2e770 100644 --- a/Assets/Scripts/Actions/TextTipAction.cs +++ b/Assets/Scripts/Actions/TextTipAction.cs @@ -53,6 +53,15 @@ public class TextTipAction : IAction data.audio = datas.ContainsKey("audio") ? datas["audio"] : string.Empty; data.title = datas.ContainsKey("title") ? datas["title"] : string.Empty; data.btns = datas.ContainsKey("btns") ? datas["btns"].Split(',').ToList() : null; + if (datas.ContainsKey("alpha")) + { + if (float.TryParse(datas["alpha"], out data.alpha) == false) + { + data.alpha = 0; + } + } + + UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); } diff --git a/Assets/Scripts/UI/UITextTip.Designer.cs b/Assets/Scripts/UI/UITextTip.Designer.cs index f1187906..6d510cd4 100644 --- a/Assets/Scripts/UI/UITextTip.Designer.cs +++ b/Assets/Scripts/UI/UITextTip.Designer.cs @@ -5,11 +5,13 @@ using QFramework; namespace QFramework.Example { - // Generate Id:2bccd644-ac9b-4f30-8f17-4a933167afc1 + // Generate Id:81b68f1b-6a7e-4133-9c0a-5297fa12f3ca public partial class UITextTip { public const string Name = "UITextTip"; + [SerializeField] + public UnityEngine.UI.Image Mask; [SerializeField] public TMPro.TextMeshProUGUI Title; [SerializeField] @@ -23,6 +25,7 @@ namespace QFramework.Example protected override void ClearUIComponents() { + Mask = null; Title = null; Des = null; BtnContent = null; diff --git a/Assets/Scripts/UI/UITextTip.cs b/Assets/Scripts/UI/UITextTip.cs index ba70f722..56699625 100644 --- a/Assets/Scripts/UI/UITextTip.cs +++ b/Assets/Scripts/UI/UITextTip.cs @@ -14,6 +14,7 @@ namespace QFramework.Example public string text; public string audio; public string title; + public float alpha = 0; public List btns; } public partial class UITextTip : UIPanel @@ -64,6 +65,9 @@ namespace QFramework.Example loader.LoadAsync(); } Title.text = mData.title; + Color color = Mask.color; + color.a = mData.alpha; + Mask.color = color; } protected override void OnShow() diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index ebf68358..60bfbd53 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -834,6 +834,11 @@ namespace XMLTool { act.args.Add("title", title.Value); } + XAttribute alpha = action.Attribute("alpha"); + if (alpha != null) + { + act.args.Add("alpha", alpha.Value); + } newAction = act; } diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index 17a52109..34ad9062 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -104,8 +104,10 @@ 如果不配置 nearPos或者normalPos 则自动隐藏对应的视角UI按钮 --> - - + +