diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index fe72080c..67a6beb7 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -96,6 +96,9 @@ public class ActionHelper case "Rotate": var rotate = (XMLTool.MoveOrAction)act; return RotateAction.Allocate(act.Value, rotate.to, rotate.time); + case "Scale": + var scaleAct = (XMLTool.MoveOrAction)act; + return ScaleAction.Allocate(act.Value, scaleAct.to, scaleAct.time); case "Btns": return BtnsAction.Allocate(act.Value); case "Anim": diff --git a/Assets/Scripts/Actions/HighLightAction.cs b/Assets/Scripts/Actions/HighLightAction.cs index 94ae7fdd..23d6a50a 100644 --- a/Assets/Scripts/Actions/HighLightAction.cs +++ b/Assets/Scripts/Actions/HighLightAction.cs @@ -51,7 +51,6 @@ namespace QFramework if (isHigh) { var effect = obj.GetOrAddComponent(); - obj.GetOrAddComponent(); effect.outlineColor = color; effect.highlighted = true; } diff --git a/Assets/Scripts/Actions/ScaleAction.cs b/Assets/Scripts/Actions/ScaleAction.cs new file mode 100644 index 00000000..8baff98f --- /dev/null +++ b/Assets/Scripts/Actions/ScaleAction.cs @@ -0,0 +1,65 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using QFramework; +using System; +using QFramework.Example; +using DG.Tweening; +public class ScaleAction : IAction +{ + public ulong ActionID { get; set; } + public bool Deinited { get; set; } + public bool Paused { get; set; } + public ActionStatus Status { get; set; } + + + private static readonly SimpleObjectPool mPool = + new SimpleObjectPool(() => new ScaleAction(), null, 10); + + Vector3 scale; + float time; + string path; + public static ScaleAction Allocate(string path, Vector3 scale, float time, System.Action onDelayFinish = null) + { + var retNode = mPool.Allocate(); + retNode.ActionID = ActionKit.ID_GENERATOR++; + retNode.Deinited = false; + retNode.Reset(); + retNode.scale = scale; + retNode.time = time; + retNode.path = path; + return retNode; + } + + + + public void Deinit() + { + if (!Deinited) + { + Deinited = true; + mPool.Recycle(this); + } + } + + public void OnExecute(float dt) + { + } + + public void OnFinish() + { + } + + public void OnStart() + { + GameObject obj = Utility.FindObj(path); + obj.transform.DOScale(scale, time).onComplete = () => this.Finish(); ; + + } + + public void Reset() + { + Status = ActionStatus.NotStart; + Paused = false; + } +} diff --git a/Assets/Scripts/Actions/ScaleAction.cs.meta b/Assets/Scripts/Actions/ScaleAction.cs.meta new file mode 100644 index 00000000..0bc9f283 --- /dev/null +++ b/Assets/Scripts/Actions/ScaleAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6bb2c14fa99141e4d9eba12563d28939 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index fa521ddf..0dda1e7f 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -308,6 +308,7 @@ namespace XMLTool { case "Move": case "Rotate": + case "Scale": { var act = new MoveOrAction(); act.to = Utility.GetVector3FromStrArray(action.Attribute("to").Value);