Add InfoBox attribute

This commit is contained in:
VladV 2022-05-18 21:29:26 +03:00
parent 89aff42a3c
commit e354cf2843
5 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,19 @@
using TriInspector;
using TriInspector.Drawers;
using TriInspector.Elements;
[assembly: RegisterTriAttributeDrawer(typeof(InfoBoxDrawer), TriDrawerOrder.System)]
namespace TriInspector.Drawers
{
public class InfoBoxDrawer : TriAttributeDrawer<InfoBoxAttribute>
{
public override TriElement CreateElement(TriProperty property, TriElement next)
{
var container = new TriElement();
container.AddChild(new TriInfoBoxElement(Attribute.Text, Attribute.MessageType));
container.AddChild(next);
return container;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 511918057d2f46238db086d6471d660e
timeCreated: 1652897510

View File

@ -23,6 +23,8 @@ namespace TriInspector.Elements
public override void OnGUI(Rect position)
{
position = EditorGUI.IndentedRect(position);
using (TriGuiHelper.PushColor(_color))
{
GUI.Label(position, string.Empty, Styles.InfoBoxBg);

View File

@ -0,0 +1,19 @@
using System;
using System.Diagnostics;
namespace TriInspector
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)]
[Conditional("UNITY_EDITOR")]
public class InfoBoxAttribute : Attribute
{
public string Text { get; }
public TriMessageType MessageType { get; }
public InfoBoxAttribute(string text, TriMessageType messageType = TriMessageType.Info)
{
Text = text;
MessageType = messageType;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 573a31308ca14b5381aa18ffbff0afe2
timeCreated: 1652897457