Last active
March 14, 2025 10:38
-
-
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.
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
| #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