From 09435dd391158b52c54b4a0adfb6f06c462c7067 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 27 Feb 2025 15:46:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Etimeline=20=E9=80=9F=E5=BA=A6?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Actions/TimeLineAction.cs | 8 ++++++++ Assets/Scripts/Xml/XmlParser.cs | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/Assets/Scripts/Actions/TimeLineAction.cs b/Assets/Scripts/Actions/TimeLineAction.cs index 114b435c..2b0c293d 100644 --- a/Assets/Scripts/Actions/TimeLineAction.cs +++ b/Assets/Scripts/Actions/TimeLineAction.cs @@ -22,6 +22,7 @@ public class TimeLineAction : IAction string frame; string endFrame; float curEndFrame = -1; + string speed = "1"; GameObject obj = null; PlayableDirector play = null; float fps = 24; @@ -38,6 +39,7 @@ public class TimeLineAction : IAction retNode.isWait = datas.ContainsKey("isWait") ? datas["isWait"] : "true"; retNode.frame = datas.ContainsKey("frame") ? datas["frame"] : string.Empty; retNode.endFrame = datas.ContainsKey("endFrame") ? datas["endFrame"] : string.Empty; + retNode.speed = datas.ContainsKey("speed") ? datas["speed"] : string.Empty; retNode.curEndFrame = -1; retNode.play = null; return retNode; @@ -102,6 +104,12 @@ public class TimeLineAction : IAction float.TryParse(frame, out curFrame); } play.time = curFrame / fps; + float curSpeed = 1; + if (float.TryParse(speed, out curSpeed) == false) + { + curSpeed = 1; + } + play.playableGraph.GetRootPlayable(0).SetSpeed(curSpeed); play.Play(); if (string.IsNullOrEmpty(endFrame) == false) diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index ad826cc4..d601aa03 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -1230,6 +1230,11 @@ namespace XMLTool { act.args.Add("endFrame", endFrame.Value); } + XAttribute speed = action.Attribute("speed"); + if (speed != null) + { + act.args.Add("speed", speed.Value); + } newAction = act; } break;