diff --git a/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs b/Aseprite2Unity/Assets/Aseprite2Unity/Editor/AsepriteImporter.cs index 513ce42..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; @@ -421,7 +427,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; } 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."));