Last active
September 3, 2019 14:04
-
-
Save szethh/5903459097d3a6d5e16e2d591d763db3 to your computer and use it in GitHub Desktop.
RichTextAreaAttribute #unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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