Created
January 27, 2015 19:39
-
-
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. :)
This file contains hidden or 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 UnityEngine; | |
| using System.Collections; | |
| public class Comment : MonoBehaviour { | |
| public string comment; | |
| } |
This file contains hidden or 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 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