Tri-Inspector/Editor.Extras/Drawers/ShowDrawerChainDrawer.cs

38 lines
1.1 KiB
C#
Raw Normal View History

2021-12-07 10:20:36 -05:00
using System.Collections.Generic;
using System.Text;
using TriInspector;
using TriInspector.Drawers;
using TriInspector.Elements;
2022-01-08 12:25:50 -05:00
[assembly: RegisterTriAttributeDrawer(typeof(ShowDrawerChainDrawer), TriDrawerOrder.System)]
2021-12-07 10:20:36 -05:00
namespace TriInspector.Drawers
{
2022-01-06 12:11:27 -05:00
public class ShowDrawerChainDrawer : TriAttributeDrawer<ShowDrawerChainAttribute>
2021-12-07 10:20:36 -05:00
{
2022-01-06 12:11:27 -05:00
public override TriElement CreateElement(TriProperty property, TriElement next)
2021-12-07 10:20:36 -05:00
{
2022-01-06 12:11:27 -05:00
return new TriDrawerChainInfoElement(property.AllDrawers, next);
2021-12-07 10:20:36 -05:00
}
}
public class TriDrawerChainInfoElement : TriElement
{
2022-01-06 12:11:27 -05:00
public TriDrawerChainInfoElement(IReadOnlyList<TriCustomDrawer> drawers, TriElement next)
2021-12-07 10:20:36 -05:00
{
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()));
2022-01-06 12:11:27 -05:00
AddChild(next);
2021-12-07 10:20:36 -05:00
}
}
}