扩展动画Action的参数 frame
This commit is contained in:
parent
24f97fedbb
commit
98169cd3d4
@ -100,8 +100,8 @@ public class ActionHelper
|
|||||||
return BtnsAction.Allocate(act.Value);
|
return BtnsAction.Allocate(act.Value);
|
||||||
case "Anim":
|
case "Anim":
|
||||||
{
|
{
|
||||||
var strAction = (XMLTool.StringListAction)act;
|
var strAction = (XMLTool.DictionaryAction)act;
|
||||||
return QFramework.AnimationAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
|
return QFramework.AnimationAction.Allocate(act.Value, strAction.args);
|
||||||
}
|
}
|
||||||
case "UITools":
|
case "UITools":
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
namespace QFramework
|
namespace QFramework
|
||||||
{
|
{
|
||||||
@ -20,17 +22,19 @@ namespace QFramework
|
|||||||
|
|
||||||
string path;
|
string path;
|
||||||
string animName;
|
string animName;
|
||||||
bool reset = false;
|
|
||||||
Animation anim;
|
Animation anim;
|
||||||
public static AnimationAction Allocate(string path, string animName, string reset, System.Action OnFinished = null)
|
string frame;
|
||||||
|
string speed;
|
||||||
|
public static AnimationAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
|
||||||
{
|
{
|
||||||
var retNode = mPool.Allocate();
|
var retNode = mPool.Allocate();
|
||||||
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||||
retNode.Deinited = false;
|
retNode.Deinited = false;
|
||||||
retNode.Reset();
|
retNode.Reset();
|
||||||
retNode.path = path;
|
retNode.path = path;
|
||||||
retNode.animName = animName;
|
retNode.animName = datas.ContainsKey("animName") ? datas["animName"] : "";
|
||||||
bool.TryParse(reset, out retNode.reset);
|
retNode.frame = datas.ContainsKey("frame") ? datas["frame"] : "";
|
||||||
|
retNode.speed = datas.ContainsKey("speed") ? datas["speed"] : "";
|
||||||
retNode.OnFinished = OnFinished;
|
retNode.OnFinished = OnFinished;
|
||||||
return retNode;
|
return retNode;
|
||||||
}
|
}
|
||||||
@ -45,10 +49,25 @@ namespace QFramework
|
|||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
anim = obj.GetComponent<Animation>();
|
anim = obj.GetComponent<Animation>();
|
||||||
anim.Play(animName);
|
|
||||||
if (reset)
|
if (string.IsNullOrEmpty(frame) == false && frame != "-1")
|
||||||
{
|
{
|
||||||
ActionKit.DelayFrame(1, () => anim.Stop()).StartGlobal();
|
int curFrame = 0;
|
||||||
|
int.TryParse(frame, out curFrame);
|
||||||
|
anim[animName].time = curFrame / anim.clip.frameRate;
|
||||||
|
anim[animName].speed = 0;
|
||||||
|
anim.Play(animName);
|
||||||
|
this.Finish();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float curSpeed = 1;
|
||||||
|
if (string.IsNullOrEmpty(speed)==false)
|
||||||
|
{
|
||||||
|
float.TryParse(speed, out curSpeed);
|
||||||
|
}
|
||||||
|
anim[animName].speed = curSpeed;
|
||||||
|
anim.Play(animName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -358,24 +358,21 @@ namespace XMLTool
|
|||||||
break;
|
break;
|
||||||
case "Anim":
|
case "Anim":
|
||||||
{
|
{
|
||||||
var act = new StringListAction();
|
var act = new DictionaryAction();
|
||||||
var animName = action.Attribute("animName");
|
var animName = action.Attribute("animName");
|
||||||
if (animName != null)
|
if (animName != null)
|
||||||
{
|
{
|
||||||
act.args.Add(animName.Value);
|
act.args.Add("animName",animName.Value);
|
||||||
}
|
}
|
||||||
else
|
var frame = action.Attribute("frame");
|
||||||
|
if (frame != null)
|
||||||
{
|
{
|
||||||
act.args.Add("");
|
act.args.Add("frame", frame.Value);
|
||||||
}
|
}
|
||||||
var reset = action.Attribute("reset");
|
var speed = action.Attribute("speed");
|
||||||
if (reset != null)
|
if (speed != null)
|
||||||
{
|
{
|
||||||
act.args.Add(reset.Value);
|
act.args.Add("speed", speed.Value);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
act.args.Add("false");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newAction = act;
|
newAction = act;
|
||||||
|
|||||||
@ -17,8 +17,8 @@
|
|||||||
<Action type="Scale" value="Main Camera" to="0,180,0" time="0"></Action>
|
<Action type="Scale" value="Main Camera" to="0,180,0" time="0"></Action>
|
||||||
<!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步-->
|
<!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步-->
|
||||||
<Action type="NextOperation"></Action>
|
<Action type="NextOperation"></Action>
|
||||||
<!--播放动画 reset=true则动画停在第一帧-->
|
<!--播放动画 reset=true则动画停在第一帧 frame是指定格在动画的某一帧 如果为-1 正常播放动画 -->
|
||||||
<Action type="Anim" value="物体路径" animName="动画名字" reset="false"></Action>
|
<Action type="Anim" value="物体路径" animName="动画名字" frame="-1"></Action>
|
||||||
<!--右下角生成按钮 可生成多个 用逗号分开-->
|
<!--右下角生成按钮 可生成多个 用逗号分开-->
|
||||||
<Action type="Btns" value="按钮1,按钮2,按钮3"></Action>
|
<Action type="Btns" value="按钮1,按钮2,按钮3"></Action>
|
||||||
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 -->
|
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user