mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 08:18:49 -05:00
Add InfoBox attribute
This commit is contained in:
parent
89aff42a3c
commit
e354cf2843
19
Editor.Extras/Drawers/InfoBoxDrawer.cs
Normal file
19
Editor.Extras/Drawers/InfoBoxDrawer.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
3
Editor.Extras/Drawers/InfoBoxDrawer.cs.meta
Normal file
3
Editor.Extras/Drawers/InfoBoxDrawer.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 511918057d2f46238db086d6471d660e
|
||||
timeCreated: 1652897510
|
@ -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);
|
||||
|
19
Runtime/Attributes/InfoBoxAttribute.cs
Normal file
19
Runtime/Attributes/InfoBoxAttribute.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
3
Runtime/Attributes/InfoBoxAttribute.cs.meta
Normal file
3
Runtime/Attributes/InfoBoxAttribute.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 573a31308ca14b5381aa18ffbff0afe2
|
||||
timeCreated: 1652897457
|
Loading…
Reference in New Issue
Block a user