diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/UICommon/XUISpriteAnimation.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/UICommon/XUISpriteAnimation.cs')
-rw-r--r-- | Client/Assets/Scripts/UICommon/XUISpriteAnimation.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/UICommon/XUISpriteAnimation.cs b/Client/Assets/Scripts/UICommon/XUISpriteAnimation.cs new file mode 100644 index 00000000..73b379b9 --- /dev/null +++ b/Client/Assets/Scripts/UICommon/XUISpriteAnimation.cs @@ -0,0 +1,74 @@ +using System;
+using UILib;
+using UnityEngine;
+
+public delegate void SpriteAnimationFinishEventHandler();
+public class XUISpriteAnimation : XUIObject, IXUISpriteAnimation
+{
+ protected override void OnAwake()
+ {
+ base.OnAwake();
+
+ m_Animation = GetComponent<UISpriteAnimation>();
+ if (m_Animation == null)
+ {
+ Debug.Log("no UISpriteAnimation component");
+ }
+ }
+
+ public void SetNamePrefix(string name)
+ {
+ m_Animation.namePrefix = name;
+ m_Animation.Reset();
+ }
+
+ public void SetNamePrefix(string atlas, string name)
+ {
+ m_Animation.sprite.SetAtlas("atlas/UI/" + atlas);
+ SetNamePrefix(name);
+ }
+
+ public void SetFrameRate(int rate)
+ {
+ m_Animation.framesPerSecond = rate;
+ }
+
+ public void Reset()
+ {
+ m_Animation.Reset();
+ m_Animation.LastLoopFinishTime = RealTime.time;
+ }
+
+ public void StopAndReset()
+ {
+ m_Animation.StopAndReset();
+ }
+
+ public void RegisterFinishCallback(SpriteAnimationFinishCallback callback)
+ {
+ if (callback != null)
+ {
+ m_FinishCallback = callback;
+ m_Animation.FinishHandler = _SpriteAnimationFinished;
+ }
+ }
+
+ public void MakePixelPerfect()
+ {
+ if (m_Animation != null && m_Animation.sprite != null)
+ m_Animation.sprite.MakePixelPerfect();
+ }
+
+ public void _SpriteAnimationFinished()
+ {
+ if (m_FinishCallback != null)
+ m_FinishCallback(this);
+ }
+
+
+
+ private UISpriteAnimation m_Animation;
+ SpriteAnimationFinishCallback m_FinishCallback;
+
+
+}
|