From d3c331c5578a040606691eb0ce5214dbd06ba96f Mon Sep 17 00:00:00 2001 From: Alex Schearer Date: Tue, 22 Feb 2022 11:21:55 -0800 Subject: [PATCH 1/2] Scaling key frame time by frame rate. --- Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs b/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs index 513ce42..5d579a0 100644 --- a/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs +++ b/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs @@ -421,7 +421,7 @@ private void MakeAnimationClip(string name, bool isLooping, List frameIndic var key = new ObjectReferenceKeyframe(); key.time = time; key.value = m_Sprites[frameIndex]; - time += m_Frames[frameIndex].FrameDurationMs / 1000.0f; + time += (m_Frames[frameIndex].FrameDurationMs / 1000.0f) * (60f / clip.frameRate); keys[i] = key; } From 91081ca9efcaeff368743a92afe1d355cf3df0bf Mon Sep 17 00:00:00 2001 From: Alex Schearer Date: Fri, 25 Feb 2022 10:51:34 -0800 Subject: [PATCH 2/2] Exposing property to set SpriteRenderer's material on import --- .../Assets/Aseprite2Unity/Editor/AsepriteImporter.cs | 6 ++++++ .../Assets/Aseprite2Unity/Editor/AsepriteImporterEditor.cs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs b/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs index 5d579a0..7fe082d 100644 --- a/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs +++ b/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs @@ -19,6 +19,7 @@ public class AsepriteImporter : ScriptedImporter, IAseVisitor // Editor fields public float m_PixelsPerUnit = 100.0f; public SpriteAtlas m_SpriteAtlas; + public Material m_SpriteMaterial; public float m_FrameRate = 60.0f; public string m_SortingLayerName; public int m_SortingOrder; @@ -95,6 +96,11 @@ public void EndFileVisit(AseFile file) var renderer = m_GameObject.AddComponent(); renderer.sprite = m_Sprites[0]; + if (m_SpriteMaterial != null) + { + renderer.material = m_SpriteMaterial; + } + renderer.sortingLayerName = m_SortingLayerName; renderer.sortingOrder = m_SortingOrder; diff --git a/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporterEditor.cs b/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporterEditor.cs index 563e310..558b29d 100644 --- a/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporterEditor.cs +++ b/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporterEditor.cs @@ -46,6 +46,9 @@ public override void OnInspectorGUI() EditorGUILayout.PropertyField(serializedObject.FindProperty("m_SpriteAtlas"), new GUIContent("Sprite Atlas", "The sprites created by this import will be made part of this sprite atlas.")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("m_SpriteMaterial"), + new GUIContent("Sprite Material", "Material for the SpriteRenderer.")); + DisplayStringChoiceProperty(serializedObject.FindProperty("m_SortingLayerName"), SortingLayer.layers.Select(l => l.name).ToArray(), new GUIContent("Sorting Layer", "Name of the SpriteRenderer's sorting layer."));