PO/Library/PackageCache/com.unity.2d.animation@5.0.7/Editor/SpriteLib/SpriteLibraryInspector.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2022-01-12 10:06:03 +03:00
using UnityEngine.Experimental.U2D.Animation;
namespace UnityEditor.Experimental.U2D.Animation
{
[CustomEditor(typeof(SpriteLibrary))]
[CanEditMultipleObjects]
internal class SpriteLibraryInspector : Editor
{
private SerializedProperty m_SpriteLib;
public void OnEnable()
{
m_SpriteLib = serializedObject.FindProperty("m_SpriteLibraryAsset");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_SpriteLib);
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
foreach (var t in targets)
{
var srs = (t as SpriteLibrary).GetComponentsInChildren<SpriteResolver>();
foreach (var sr in srs)
{
sr.ResolveSpriteToSpriteRenderer();
sr.spriteLibChanged = true;
}
}
}
}
}
}