14 [CustomEditor(typeof(Comment))]
17 private SerializedProperty _isEditing;
18 private GUIStyle _editStyle;
19 private GUIStyle _displayStyle;
24 _isEditing = serializedObject.FindProperty(
"_isEditing");
31 private void drawComment(SerializedProperty commentProp) {
32 string text = commentProp.stringValue;
34 if (_editStyle ==
null) {
35 _editStyle =
new GUIStyle(EditorStyles.textArea);
36 _editStyle.wordWrap =
true;
39 if (_displayStyle ==
null) {
40 _displayStyle =
new GUIStyle(EditorStyles.label);
41 _displayStyle.wordWrap =
true;
42 _displayStyle.richText =
true;
45 if (
string.IsNullOrEmpty(text)) {
46 _isEditing.boolValue =
true;
49 if (_isEditing.boolValue) {
50 if (GUILayout.Button(
"Finish")) {
51 _isEditing.boolValue =
false;
54 commentProp.stringValue = EditorGUILayout.TextArea(text, _editStyle);
56 EditorGUILayout.Space();
57 var rect = GUILayoutUtility.GetRect(
new GUIContent(text), _displayStyle);
58 EditorGUI.SelectableLabel(rect, text, _displayStyle);
void dontShowScriptField()
void specifyCustomDrawer(string propertyName, Action< SerializedProperty > propertyDrawer)
Specify a callback to be used to draw a specific named property. Should be called in OnEnable.