FInspectorWindow.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections.Generic;
  4. using Flux;
  5. namespace FluxEditor
  6. {
  7. public class FInspectorWindow : EditorWindow {
  8. public static FInspectorWindow _instance = null;
  9. //[MenuItem(FSequenceEditorWindow.MENU_PATH+FSequenceEditorWindow.PRODUCT_NAME+"/Open Inspector", false, 1)]
  10. public static void Open()
  11. {
  12. _instance = GetWindow<FInspectorWindow>();
  13. _instance.Show();
  14. _instance.titleContent = new GUIContent("Event Inspector");
  15. }
  16. private Vector2 _scroll = Vector2.zero;
  17. private FSequenceEditor _sequenceEditor = null;
  18. public void SetSequenceEditor( FSequenceEditor sequenceEditor ){ _sequenceEditor = sequenceEditor; }
  19. private Rect _viewRect;
  20. void OnEnable()
  21. {
  22. _instance = this;
  23. hideFlags = HideFlags.DontSave;
  24. wantsMouseMove = true;
  25. autoRepaintOnSceneChange = true;
  26. }
  27. void OnDestroy()
  28. {
  29. }
  30. public void Render( Rect rect )
  31. {
  32. float contentWidth = rect.width;
  33. contentWidth -= rect.height < _viewRect.height ? 20 : 8;
  34. _scroll = GUI.BeginScrollView( rect, _scroll, _viewRect );
  35. EditorGUI.BeginChangeCheck();
  36. GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);
  37. _sequenceEditor.EventSelection.OnInspectorGUI( contentWidth );
  38. if( _sequenceEditor.EventSelection.Editors.Count > 0 )
  39. GUILayout.Space(10);
  40. _sequenceEditor.TrackSelection.OnInspectorGUI( contentWidth );
  41. _sequenceEditor.TimelineSelection.OnInspectorGUI( contentWidth );
  42. _sequenceEditor.ContainerSelection.OnInspectorGUI( contentWidth );
  43. if( EditorGUI.EndChangeCheck() )
  44. {
  45. _sequenceEditor.Repaint();
  46. }
  47. GUILayout.Space(1);
  48. if( Event.current.type == EventType.Repaint )
  49. {
  50. Rect lastElementRect = GUILayoutUtility.GetLastRect();
  51. _viewRect = rect;
  52. _viewRect.height = Mathf.Max( _viewRect.height, lastElementRect.y + lastElementRect.height );
  53. }
  54. GUI.EndScrollView();
  55. }
  56. void OnGUI()
  57. {
  58. if( _sequenceEditor == null )
  59. return;
  60. Rect rect = position;
  61. rect.x = 0; rect.y = 0;
  62. Render( rect );
  63. }
  64. void Update()
  65. {
  66. if( _sequenceEditor == null && FSequenceEditorWindow.instance != null )
  67. {
  68. _sequenceEditor = FSequenceEditorWindow.instance.GetSequenceEditor();
  69. }
  70. if( _sequenceEditor != null && (_sequenceEditor.EventSelection.IsDirty
  71. || _sequenceEditor.TrackSelection.IsDirty
  72. || _sequenceEditor.TimelineSelection.IsDirty
  73. || _sequenceEditor.ContainerSelection.IsDirty) )
  74. {
  75. Repaint();
  76. }
  77. }
  78. }
  79. }