Tri-Inspector/Editor.Extras/Drawers/ShowDrawerChainDrawer.cs
2022-01-08 20:25:50 +03:00

38 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.Text;
using TriInspector;
using TriInspector.Drawers;
using TriInspector.Elements;
[assembly: RegisterTriAttributeDrawer(typeof(ShowDrawerChainDrawer), TriDrawerOrder.System)]
namespace TriInspector.Drawers
{
public class ShowDrawerChainDrawer : TriAttributeDrawer<ShowDrawerChainAttribute>
{
public override TriElement CreateElement(TriProperty property, TriElement next)
{
return new TriDrawerChainInfoElement(property.AllDrawers, next);
}
}
public class TriDrawerChainInfoElement : TriElement
{
public TriDrawerChainInfoElement(IReadOnlyList<TriCustomDrawer> drawers, TriElement next)
{
var info = new StringBuilder();
info.Append("Drawer Chain:");
for (var i = 0; i < drawers.Count; i++)
{
var drawer = drawers[i];
info.AppendLine();
info.Append(i).Append(": ").Append(drawer.GetType().Name);
}
AddChild(new TriInfoBoxElement(info.ToString()));
AddChild(next);
}
}
}