CommentsInspector.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4. namespace RootMotion {
  5. [CustomEditor(typeof(Comments))]
  6. public class CommentsInspector : Editor {
  7. private Comments script { get { return target as Comments; }}
  8. private GUIStyle style = new GUIStyle();
  9. // Black and white
  10. //private static Color pro = new Color(0.7f, 0.7f, 0.7f, 1f);
  11. //private static Color free = new Color(0, 0, 0, 1);
  12. // Colors
  13. private static Color pro = new Color(0.5f, 0.7f, 0.3f, 1f);
  14. private static Color free = new Color(0.2f, 0.3f, 0.1f, 1f);
  15. public override void OnInspectorGUI() {
  16. if (serializedObject == null) return;
  17. style.wordWrap = true;
  18. style.normal.textColor = EditorGUIUtility.isProSkin? pro: free;
  19. serializedObject.Update();
  20. EditorGUILayout.Space();
  21. string text = EditorGUILayout.TextArea(script.text, style);
  22. if (text != script.text) {
  23. Undo.RecordObject(script, "Edit Comments");
  24. script.text = text;
  25. }
  26. EditorGUILayout.Space();
  27. serializedObject.ApplyModifiedProperties();
  28. }
  29. }
  30. }