Skip to content

Commit 7d26e45

Browse files
committed
better works with packed sprites in editor mode
1 parent 816c8c1 commit 7d26e45

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

Runtime/ImageAnimator3000.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private static void EditorCreateAsset()
4343

4444
var image = obj.gameObject.AddComponent<Image>();
4545
image.sprite = UnityEditor.AssetDatabase.GetBuiltinExtraResource<Sprite>("UI/Skin/UISprite.psd");
46-
image.type = UnityEngine.UI.Image.Type.Sliced;
46+
image.type = Image.Type.Simple;
4747
return image;
4848
});
4949
}

Runtime/SpriteAnimationClip3000.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,14 @@ public Sprite GetFrameSprite(string spriteName)
103103
#endif
104104
if (m_sprites == null)
105105
{
106-
#if UNITY_EDITOR
107106
var available = true;
108-
switch (EditorSettings.spritePackerMode)
107+
#if UNITY_EDITOR
108+
available &= EditorSettings.spritePackerMode != SpritePackerMode.Disabled;
109+
if (m_spriteAtlas != null)
109110
{
110-
case SpritePackerMode.BuildTimeOnlyAtlas:
111-
if (m_spriteAtlas != null)
112-
SpriteAtlasUtility.PackAtlases(new[] { m_spriteAtlas }, EditorUserBuildSettings.activeBuildTarget, canCancel: false);
113-
break;
114-
115-
case SpritePackerMode.AlwaysOnAtlas:
116-
//do nothing, this SpriteAtlas packed already
117-
break;
118-
119-
case SpritePackerMode.Disabled:
120-
//shouble be return null, because no one sprite available
121-
available = false;
122-
break;
111+
var packables = m_spriteAtlas.GetPackables();
112+
if (m_spriteAtlas.spriteCount != packables.Length)
113+
SpriteAtlasUtility.PackAtlases(new[] { m_spriteAtlas }, EditorUserBuildSettings.activeBuildTarget, canCancel: false);
123114
}
124115
#endif
125116
if (available && m_spriteAtlas != null)

0 commit comments

Comments
 (0)