diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index 15c1d086..6c22e183 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -131,7 +131,7 @@ public class ActionHelper case "TextTip": { var strAction = (XMLTool.StringListAction)act; - return TextTipAction.Allocate(act.Value, strAction.args[0]); + return TextTipAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); } case "UIShow": { diff --git a/Assets/Scripts/Actions/TextTipAction.cs b/Assets/Scripts/Actions/TextTipAction.cs index 3d609c2f..cf389f04 100644 --- a/Assets/Scripts/Actions/TextTipAction.cs +++ b/Assets/Scripts/Actions/TextTipAction.cs @@ -17,7 +17,8 @@ public class TextTipAction : IAction new SimpleObjectPool(() => new TextTipAction(), null, 10); string text = string.Empty; string btns = string.Empty; - public static TextTipAction Allocate(string text, string btns, System.Action onDelayFinish = null) + string audio = string.Empty; + public static TextTipAction Allocate(string text,string audio , string btns, System.Action onDelayFinish = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; @@ -25,6 +26,7 @@ public class TextTipAction : IAction retNode.Reset(); retNode.text = text; retNode.btns = btns; + retNode.audio = audio; return retNode; } @@ -52,6 +54,7 @@ public class TextTipAction : IAction UITextTipData data = new UITextTipData(); data.text = text; data.btns = btns.Split(',').ToList(); + data.audio = audio; UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); } diff --git a/Assets/Scripts/UI/UIHint.cs b/Assets/Scripts/UI/UIHint.cs index 769ffc88..10eeda15 100644 --- a/Assets/Scripts/UI/UIHint.cs +++ b/Assets/Scripts/UI/UIHint.cs @@ -68,6 +68,7 @@ namespace QFramework.Example protected override void OnClose() { SetItem(0); + loader.Recycle2Cache(); } } } diff --git a/Assets/Scripts/UI/UITextTip.cs b/Assets/Scripts/UI/UITextTip.cs index fbf2a899..8f1bc38a 100644 --- a/Assets/Scripts/UI/UITextTip.cs +++ b/Assets/Scripts/UI/UITextTip.cs @@ -9,11 +9,12 @@ namespace QFramework.Example public class UITextTipData : UIPanelData { public string text; - + public string audio; public List btns; } public partial class UITextTip : UIPanel { + ResLoader loader; protected override void OnInit(IUIData uiData = null) { @@ -36,6 +37,19 @@ namespace QFramework.Example Hide(); }); } + if (string.IsNullOrEmpty(mData.audio) == false) + { + string path = Global.audioPath + mData.audio; + loader = ResLoader.Allocate(); + loader.Add2Load(path.ToLocalAudioResName(), (success, res) => + { + if (success) + { + AudioKit.PlayVoice(res.Asset.As(), false); + } + }); + loader.LoadAsync(); + } } protected override void OnShow() @@ -48,6 +62,7 @@ namespace QFramework.Example protected override void OnClose() { + loader.Recycle2Cache(); } } } diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index e69e90db..0144bf56 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -551,6 +551,15 @@ namespace XMLTool case "TextTip": { var act = new StringListAction(); + XAttribute audio = action.Attribute("audio"); + if (audio != null) + { + act.args.Add(audio.Value); + } + else + { + act.args.Add(""); + } XAttribute btns = action.Attribute("btns"); if (btns != null) { diff --git a/Data/App.xml b/Data/App.xml index c0027c51..9af441da 100644 --- a/Data/App.xml +++ b/Data/App.xml @@ -733,7 +733,7 @@ - +