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

This commit is contained in:
李浩 2024-12-18 13:18:30 +08:00
commit 1fcff22d0f
7 changed files with 184 additions and 16 deletions

View File

@ -10,10 +10,6 @@ namespace XMLTool
public float time;
}
public class AnimationAction : Action
{
public string animName;
}
public class StringListAction : Action

View File

@ -99,8 +99,10 @@ public class ActionHelper
case "Btns":
return BtnsAction.Allocate(act.Value);
case "Anim":
var anim = (XMLTool.AnimationAction)act;
return QFramework.AnimationAction.Allocate(anim.Value, anim.animName);
{
var strAction = (XMLTool.StringListAction)act;
return QFramework.AnimationAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
}
case "UITools":
{
var strAction = (XMLTool.StringListAction)act;
@ -154,6 +156,11 @@ public class ActionHelper
var strAction = (XMLTool.StringListAction)act;
return VideoAction.Allocate(act.Value, strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3]);
}
case "HighLight":
{
var strAction = (XMLTool.StringListAction)act;
return HighLightAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
}
}
break;
case XMLTool.Condition condition:

View File

@ -20,15 +20,17 @@ namespace QFramework
string path;
string animName;
bool reset = false;
Animation anim;
public static AnimationAction Allocate(string path, string animName, System.Action OnFinished = null)
public static AnimationAction Allocate(string path, string animName, string reset, System.Action OnFinished = null)
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.path = path;
retNode.animName = animName;
retNode.Reset();
bool.TryParse(reset, out retNode.reset);
retNode.OnFinished = OnFinished;
return retNode;
}
@ -44,6 +46,10 @@ namespace QFramework
{
anim = obj.GetComponent<Animation>();
anim.Play(animName);
if (reset)
{
ActionKit.DelayFrame(1, () => anim.Stop());
}
}
else
{

View File

@ -0,0 +1,102 @@
using HighlightPlus;
using System;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
namespace QFramework
{
internal class HighLightAction : IAction
{
public System.Action OnFinished { get; set; }
private HighLightAction()
{
}
private static readonly SimpleObjectPool<HighLightAction> mPool =
new SimpleObjectPool<HighLightAction>(() => new HighLightAction(), null, 10);
string path;
Color color = Color.green;
bool isHigh = true;
public static HighLightAction Allocate(string path, string isHigh, string color, System.Action OnFinished = null)
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.path = path;
if (string.IsNullOrEmpty(color) == false)
{
retNode.color = Utility.ToColor(color);
}
bool.TryParse(isHigh, out retNode.isHigh);
retNode.OnFinished = OnFinished;
return retNode;
}
public ulong ActionID { get; set; }
public ActionStatus Status { get; set; }
public void OnStart()
{
GameObject obj = Utility.FindObj(path);
if (obj != null)
{
if (isHigh)
{
var effect = obj.GetOrAddComponent<HighlightEffect>();
obj.GetOrAddComponent<HighlightTrigger>();
effect.outlineColor = color;
effect.highlighted = true;
}
else
{
var effect = obj.GetComponent<HighlightEffect>();
if (effect)
{
effect.highlighted = false;
}
}
}
}
public void OnExecute(float dt)
{
this.Finish();
OnFinished?.Invoke();
}
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: 491e5e519156b5e4f9591a0221d5b824
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -317,8 +317,26 @@ namespace XMLTool
break;
case "Anim":
{
var act = new AnimationAction();
act.animName = action.Attribute("animName").Value;
var act = new StringListAction();
var animName = action.Attribute("animName");
if (animName != null)
{
act.args.Add(animName.Value);
}
else
{
act.args.Add("");
}
var reset = action.Attribute("reset");
if (reset != null)
{
act.args.Add(reset.Value);
}
else
{
act.args.Add("false");
}
newAction = act;
}
break;
@ -615,6 +633,30 @@ namespace XMLTool
newAction = act;
}
break;
case "HighLight":
{
var act = new StringListAction();
XAttribute isHigh = action.Attribute("isHigh");
if (isHigh != null)
{
act.args.Add(isHigh.Value);
}
else
{
act.args.Add("true");
}
XAttribute color = action.Attribute("color");
if (color != null)
{
act.args.Add(color.Value);
}
else
{
act.args.Add("");
}
newAction = act;
}
break;
default:
newAction = new Action();
break;

View File

@ -15,8 +15,8 @@
<Action type="Rotate" value="Main Camera" to="0,180,0" time="0"></Action>
<!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步-->
<Action type="NextOperation"></Action>
<!--播放动画-->
<Action type="Anim" value="物体路径" animName="动画名字"></Action>
<!--播放动画 reset=true则动画停在第一帧-->
<Action type="Anim" value="物体路径" animName="动画名字" reset="false"></Action>
<!--右下角生成按钮 可生成多个 用逗号分开-->
<Action type="Btns" value="按钮1,按钮2,按钮3"></Action>
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 -->
@ -25,7 +25,8 @@
rightLabel="提示:器械选择正确。"
wrongLabel="提示:器械选择错误,\r\n当前模块中不需要该物品。"
rightEvent=""
wrongEvent=""/>
wrongEvent=""></Action>
<!--物体点位选择 物体的中心点-->
<Action type="PointQuestion" value="路径1,路径2"></Action>
<!--文字选择题-->
@ -41,14 +42,17 @@
<!--文字弹窗 按钮可以多个 点击事件使用UIClick-->
<Action type="TextTip" value="这里是文字描述" audio="q001.mp3" btns="确定,取消"/>
<!--锁定镜头 value为是否锁定-->
<Action type="LockCamera" value="true" />
<Action type="LockCamera" value="true"></Action>
<!--播放视频 size为视频窗口大小 offset为窗口中心点偏移 播放完成事件和关闭事件 通常使用关闭事件即可
宽度不要小于500 否则进度条看不太清楚-->
<Action type="Video" value="test.mp4" size="500,500" offset="10,10" finishedEvent="finished" closeEvent="close"/>
<Action type="Video" value="test.mp4" size="500,500" offset="10,10" finishedEvent="finished" closeEvent="close"></Action>
<!--物体显隐 用于3D物体 isShow=true为显示 false为隐藏 UI的显隐使用UIShow-->
<Action type="Show" value="SM_QvanChangJing/sence/pPlane1" isShow="false"></Action>
<!--设置物体高亮 value是物体路径 color是rgba isHigh设置是否显示高亮-->
<Action type="HighLight" value="路径" isHigh="true" color="0,255,0,255"></Action>
<!--延迟 value是秒-->
<Action type="Delay" value="2"></Action>
<!--判断UI点击-->