Created
September 13, 2020 07:49
-
-
Save jminor/a0b9a40d322266e9ed13b800082d41fd to your computer and use it in GitHub Desktop.
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
// This adds a simple text area for you to add comments | |
// to your GameObjects in the Unity inspector. | |
// Comments are saved with your scene, just like any other | |
// component on a GameObject. | |
using UnityEngine; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
public class Comment : MonoBehaviour | |
{ | |
public string comment = ""; | |
} | |
#if UNITY_EDITOR | |
[CustomEditor(typeof(Comment))] | |
public class CommentEditor : Editor | |
{ | |
public override void OnInspectorGUI() | |
{ | |
Comment _target = (Comment)target; | |
EditorGUI.BeginChangeCheck(); | |
string newValue = GUILayout.TextArea(_target.comment); | |
if (EditorGUI.EndChangeCheck()) | |
{ | |
Undo.RecordObject(target, "Changed Comment"); | |
_target.comment = newValue; | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment