Skip to content

Instantly share code, notes, and snippets.

@fadookie
Created January 27, 2015 19:39
Show Gist options
  • Select an option

  • Save fadookie/e6cd6e3d97060416af1c to your computer and use it in GitHub Desktop.

Select an option

Save fadookie/e6cd6e3d97060416af1c to your computer and use it in GitHub Desktop.
Comment component for Unity3D for storing multiline comments in the editor inspector. Doesn't do auto linebreaks yet (you have to add them manually) but feel free to send me a patch. :)
using UnityEngine;
using System.Collections;
public class Comment : MonoBehaviour {
public string comment;
}
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(Comment))]
public class CommentDrawer : Editor {
public override void OnInspectorGUI () {
SerializedProperty comment = serializedObject.FindProperty("comment");
string newComment = EditorGUILayout.TextArea(comment.stringValue);
if (GUI.changed) {
comment.stringValue = newComment;
serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment