Skip to content

Instantly share code, notes, and snippets.

@szethh
Last active September 3, 2019 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szethh/5903459097d3a6d5e16e2d591d763db3 to your computer and use it in GitHub Desktop.
Save szethh/5903459097d3a6d5e16e2d591d763db3 to your computer and use it in GitHub Desktop.
RichTextAreaAttribute #unity
using System;
using UnityEngine;
using Sirenix.OdinInspector.Editor;
using UnityEditor;
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class RichTextAreaAttribute : Attribute
{
public bool ShowHelp { get; private set; }
public RichTextAreaAttribute()
{
ShowHelp = false;
}
public RichTextAreaAttribute(bool showHelp)
{
ShowHelp = showHelp;
}
}
public class RichTextAreaAttributeDrawer : OdinAttributeDrawer<RichTextAreaAttribute, string>
{
protected override void DrawPropertyLayout(GUIContent label)
{
GUIStyle style = new GUIStyle(GUI.skin.textArea);
style.richText = true;
if (this.Attribute.ShowHelp && GUILayout.Button("Rich Text Help"))
{
Application.OpenURL("http://digitalnativestudios.com/textmeshpro/docs/rich-text/");
}
EditorGUILayout.PrefixLabel("Text");
ValueEntry.SmartValue = EditorGUILayout.TextArea(ValueEntry.SmartValue, style);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment