扩展动画Action 新增reset参数

This commit is contained in:
shenjianxing 2024-12-18 11:17:08 +08:00
parent 10a16efdf5
commit badd820b23
5 changed files with 34 additions and 12 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;

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

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

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 做检测 -->