新增通用弹窗提示
This commit is contained in:
parent
e093f10495
commit
bf7e2678f7
@ -181,6 +181,11 @@ public class ActionHelper
|
|||||||
{
|
{
|
||||||
return DestroyAction.Allocate(act.Value);
|
return DestroyAction.Allocate(act.Value);
|
||||||
}
|
}
|
||||||
|
case "ResultTip":
|
||||||
|
{
|
||||||
|
var strAction = (XMLTool.StringListAction)act;
|
||||||
|
return ResultTipAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
Debug.LogError($"没有找到此Action的类型{act.Type}");
|
Debug.LogError($"没有找到此Action的类型{act.Type}");
|
||||||
break;
|
break;
|
||||||
|
|||||||
82
Assets/Scripts/Actions/ResultTipAction.cs
Normal file
82
Assets/Scripts/Actions/ResultTipAction.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
11
Assets/Scripts/Actions/ResultTipAction.cs.meta
Normal file
11
Assets/Scripts/Actions/ResultTipAction.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7cdaddc504b6e994eb7c5d8d8fea65d8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -812,6 +812,30 @@ namespace XMLTool
|
|||||||
newAction = act;
|
newAction = act;
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
newAction = new Action();
|
newAction = new Action();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -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>
|
<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-->
|
<!--相机锁定 是否可以移动 isMove 是否可以旋转镜头 isRotate-->
|
||||||
<Action type="CameraLock" isMove="false" isRotate="false"></Action>
|
<Action type="CameraLock" isMove="false" isRotate="false"></Action>
|
||||||
|
<!--正确和错误的弹窗 isRight 是否正确-->
|
||||||
|
<Action type="ResultTip" value="这里是一个弹窗" isRight="true" finishedEvent="关闭弹窗事件"></Action>
|
||||||
<!--预加载模块 要在app.xml的Data标签内-->
|
<!--预加载模块 要在app.xml的Data标签内-->
|
||||||
<PreLoad>
|
<PreLoad>
|
||||||
<Action type="Parallel">
|
<Action type="Parallel">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user