Merge remote-tracking branch 'origin/master' into LouDi_Pig

This commit is contained in:
李浩 2024-12-20 09:24:51 +08:00
commit 97900f2fa9
6 changed files with 125 additions and 1 deletions

View File

@ -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;

View File

@ -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<ResultTipAction> mPool =
new SimpleObjectPool<ResultTipAction>(() => 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<UIResultTip>(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; }
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7cdaddc504b6e994eb7c5d8d8fea65d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<TextMeshProUGUI>();
label.text = item;
obj.GetComponent<Button>().onClick.AddListener(() =>

View File

@ -812,6 +812,30 @@ namespace XMLTool
newAction = act;
}
break;
case "ResultTip":
{
var act = new StringListAction();
XAttribute isRight = action.Attribute("isRight");
if (isRight != null)
{
act.args.Add(isRight.Value);
}
else
{
act.args.Add("false");
}
XAttribute finishedEvent = action.Attribute("finishedEvent");
if (finishedEvent != null)
{
act.args.Add(finishedEvent.Value);
}
else
{
act.args.Add("");
}
newAction = act;
}
break;
default:
newAction = new Action();
break;

View File

@ -78,7 +78,8 @@
<Action type="Line" name="红线" value="-4.030808,2.689521,-1.768913|-3.759371,2.694512,-1.247592" color="255,0,0,255" width="0.05" lineScale="10,0.5"></Action>
<!--相机锁定 是否可以移动 isMove 是否可以旋转镜头 isRotate-->
<Action type="CameraLock" isMove="false" isRotate="false"></Action>
<!--正确和错误的弹窗 isRight 是否正确-->
<Action type="ResultTip" value="这里是一个弹窗" isRight="true" finishedEvent="关闭弹窗事件"></Action>
<!--预加载模块 要在app.xml的Data标签内-->
<PreLoad>
<Action type="Parallel">