diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index 0d421db8..8b3408d9 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -181,6 +181,11 @@ public class ActionHelper { return DestroyAction.Allocate(act.Value); } + case "ResultTip": + { + var strAction = (XMLTool.StringListAction)act; + return ResultTipAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); + } default: Debug.LogError($"ûҵAction{act.Type}"); break; diff --git a/Assets/Scripts/Actions/ResultTipAction.cs b/Assets/Scripts/Actions/ResultTipAction.cs new file mode 100644 index 00000000..998c7abc --- /dev/null +++ b/Assets/Scripts/Actions/ResultTipAction.cs @@ -0,0 +1,82 @@ +using QFramework.Example; +using System; +using UnityEngine; + +namespace QFramework +{ + internal class ResultTipAction : IAction + { + public System.Action OnFinished { get; set; } + + + private ResultTipAction() + { + } + + private static readonly SimpleObjectPool mPool = + new SimpleObjectPool(() => new ResultTipAction(), null, 10); + + public string txt; + public string isRight; + public string finishedEvent; + public static ResultTipAction Allocate(string txt, string isRight, string finishedEvent, System.Action OnFinished = null) + { + var retNode = mPool.Allocate(); + retNode.ActionID = ActionKit.ID_GENERATOR++; + retNode.Deinited = false; + retNode.Reset(); + retNode.txt = txt; + retNode.isRight = isRight; + retNode.finishedEvent = finishedEvent; + retNode.OnFinished = OnFinished; + return retNode; + } + + + public ulong ActionID { get; set; } + public ActionStatus Status { get; set; } + + public void OnStart() + { + UIResultTipData data = new UIResultTipData(); + data.label = txt; + bool.TryParse(isRight, out data.isRight); + if (string.IsNullOrEmpty(finishedEvent) == false) + { + data.callback = () => StringEventSystem.Global.Send(finishedEvent); + } + UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); + } + + public void OnExecute(float dt) + { + + } + + public void OnFinish() + { + } + + public void Reset() + { + Status = ActionStatus.NotStart; + Paused = false; + } + + public bool Paused { get; set; } + + public void Deinit() + { + if (!Deinited) + { + OnFinished = null; + Deinited = true; + mPool.Recycle(this); + } + } + + public bool Deinited { get; set; } + } + + +} \ No newline at end of file diff --git a/Assets/Scripts/Actions/ResultTipAction.cs.meta b/Assets/Scripts/Actions/ResultTipAction.cs.meta new file mode 100644 index 00000000..c37e7e06 --- /dev/null +++ b/Assets/Scripts/Actions/ResultTipAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7cdaddc504b6e994eb7c5d8d8fea65d8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/UITextQuestion.cs b/Assets/Scripts/UI/UITextQuestion.cs index 74ba9229..e6af6366 100644 --- a/Assets/Scripts/UI/UITextQuestion.cs +++ b/Assets/Scripts/UI/UITextQuestion.cs @@ -40,6 +40,7 @@ namespace QFramework.Example foreach (var item in mData.btns) { GameObject obj = GameObject.Instantiate(BtnPrefab.gameObject, BtnContent); + obj.name = item; var label = obj.transform.Find("Label").GetComponent(); label.text = item; obj.GetComponent