25 lines
828 B
C#
25 lines
828 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
[CustomEditor(typeof(UiAnimation))]
|
|
public class UiAnimationEditor : Editor
|
|
{
|
|
public override void OnInspectorGUI()
|
|
{
|
|
base.OnInspectorGUI();
|
|
if (GUILayout.Button("Sort Sprites"))
|
|
{
|
|
var component = target as UiAnimation;
|
|
if (component != null)
|
|
{
|
|
var list = new List<Sprite>(component.sprites.Length);
|
|
for (var i = 0; i < component.sprites.Length; i++)
|
|
if (component.sprites[i] != null)
|
|
list.Add(component.sprites[i]);
|
|
list.Sort((a, b) => string.Compare(a.name, b.name, StringComparison.Ordinal));
|
|
component.sprites = list.ToArray();
|
|
}
|
|
}
|
|
}
|
|
} |