summaryrefslogtreecommitdiff
path: root/WorldlineKeepers/Assets/Scripts/Rendering
diff options
context:
space:
mode:
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts/Rendering')
-rw-r--r--WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs15
-rw-r--r--WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs39
4 files changed, 61 insertions, 6 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs b/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs
new file mode 100644
index 0000000..0503c7d
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs
@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Rendering
+{
+
+ public class GraphicsManager : Singleton<GraphicsManager>
+ {
+
+ public List<Shader> m_Shaders;
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs.meta b/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs.meta
new file mode 100644
index 0000000..d98f33f
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c770205e561842a4cab48846601a1776
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs
index f2b7e98..a6c6a6d 100644
--- a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs
+++ b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs
@@ -5,7 +5,7 @@ using UnityEngine;
namespace WK.Rendering
{
-
+ [Serializable]
public class SpriteAnimation
{
public List<Sprite> sprites;
diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs
index 315cf91..63ba394 100644
--- a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs
+++ b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs
@@ -13,20 +13,49 @@ namespace WK.Rendering
#endregion
#region 公共字段
-
+ public bool playing
+ {
+ get
+ {
+ return m_IsPlaying;
+ }
+ set
+ {
+ m_IsPlaying = value;
+ }
+ }
#endregion
#region 私有字段
-
+ private SpriteRenderer m_SpriteRenderer;
+ private bool m_IsPlaying;
#endregion
private void Awake()
{
- // 私有字段赋值
+ m_SpriteRenderer = GetComponent<SpriteRenderer>();
- // 公共字段赋值
+ StartCoroutine(CoPlayAnimation(m_SpriteAnimation.duration));
- // 初始化
+ m_IsPlaying = true;
+ }
+
+ IEnumerator CoPlayAnimation(float duration = 1f)
+ {
+ int index = 0;
+ while (true)
+ {
+ if (!playing)
+ {
+ yield return null;
+ continue;
+ }
+
+ m_SpriteRenderer.sprite = m_SpriteAnimation.sprites[index];
+ yield return new WaitForSeconds(m_SpriteAnimation.duration / m_SpriteAnimation.sprites.Count);
+ index++;
+ index %= m_SpriteAnimation.sprites.Count;
+ }
}
}