Skip to content

Instantly share code, notes, and snippets.

@EudenDev
Last active March 14, 2025 10:38
Show Gist options
  • Save EudenDev/63bce070cd70823e7981c4eec39a5e93 to your computer and use it in GitHub Desktop.
Save EudenDev/63bce070cd70823e7981c4eec39a5e93 to your computer and use it in GitHub Desktop.
Comment Component for Unity, simple and compact. -- Visit my GitHub or Twitter for more Unity scripts.
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
public sealed class Comment : MonoBehaviour
{
public string commentary = "New comment.";
}
#if UNITY_EDITOR
[CustomEditor(typeof(Comment)), CanEditMultipleObjects]
public class CommmentEditor : Editor
{
SerializedProperty comment;
private void OnEnable()
{
comment = serializedObject.FindProperty("commentary");
}
public override void OnInspectorGUI()
{
// - Copy editor style
GUIStyle style = new GUIStyle(EditorStyles.label);
// - Modify this color if needed.
style.normal.textColor = new Color(0.2f, 0.5f, 0.2f);
style.wordWrap = true;
// - Draw and apply changes
comment.stringValue = GUILayout.TextArea(comment.stringValue, style);
serializedObject.ApplyModifiedProperties();
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment