Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.1 KiB

  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. [CustomPropertyDrawer(typeof(InspectorNoteAttribute))]
  6. public class DrawerInspectorNote : DecoratorDrawer
  7. {
  8. public override void OnGUI( Rect position )
  9. {
  10. InspectorNoteAttribute note = attribute as InspectorNoteAttribute;
  11. // our header is always present
  12. Rect posLabel = position;
  13. posLabel.y += 13;
  14. posLabel.x -= 2;
  15. posLabel.height += 13;
  16. EditorGUI.LabelField(posLabel, note.header, EditorStyles.whiteLargeLabel);
  17. // do we have a message too?
  18. if (!string.IsNullOrEmpty(note.message))
  19. {
  20. Color color = GUI.color;
  21. Color faded = color;
  22. faded.a = 0.6f;
  23. Rect posExplain = posLabel;
  24. posExplain.y += 15;
  25. GUI.color = faded;
  26. EditorGUI.LabelField(posExplain, note.message, EditorStyles.whiteMiniLabel);
  27. GUI.color = color;
  28. }
  29. Rect posLine = position;
  30. posLine.y += string.IsNullOrEmpty(note.message) ? 30 : 42;
  31. posLine.height = 1f;
  32. GUI.Box(posLine, "");
  33. }
  34. public override float GetHeight() {
  35. InspectorNoteAttribute note = attribute as InspectorNoteAttribute;
  36. return string.IsNullOrEmpty( note.message ) ? 38 : 50;
  37. }
  38. }
  39. [CustomPropertyDrawer( typeof( InspectorCommentAttribute ) )]
  40. public class DrawerInspectorComment : DecoratorDrawer {
  41. public override void OnGUI( Rect position ) {
  42. InspectorCommentAttribute comment = attribute as InspectorCommentAttribute;
  43. // our header is always present
  44. Rect posLabel = position;
  45. //posLabel.y += 13;
  46. //posLabel.x -= 2;
  47. //posLabel.height += 13;
  48. //EditorGUI.LabelField( posLabel, comment.header, EditorStyles.whiteLargeLabel );
  49. // do we have a message too?
  50. if ( !string.IsNullOrEmpty( comment.message ) ) {
  51. Color color = GUI.color;
  52. Color faded = color;
  53. faded.a = 0.6f;
  54. Rect posExplain = posLabel;
  55. posExplain.y += 15;
  56. GUI.color = faded;
  57. EditorGUI.LabelField( posExplain, comment.message, EditorStyles.whiteMiniLabel );
  58. GUI.color = color;
  59. }
  60. }
  61. public override float GetHeight() {
  62. InspectorNoteAttribute note = attribute as InspectorNoteAttribute;
  63. return string.IsNullOrEmpty( note.message ) ? 38 : 50;
  64. }
  65. }