FChangeFrameRateWindow.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using UnityEngine;
  2. using UnityEngine.Events;
  3. using UnityEditor;
  4. using Flux;
  5. namespace FluxEditor
  6. {
  7. public class FChangeFrameRateWindow : EditorWindow {
  8. public static void Show( Vector2 guiPos, FSequence sequence, UnityAction<FSequence, int, bool> callback )
  9. {
  10. FChangeFrameRateWindow window = CreateInstance<FChangeFrameRateWindow>();
  11. Rect r = new Rect();
  12. r.min = EditorGUIUtility.GUIToScreenPoint( guiPos );
  13. r.width = 0;
  14. r.height = 0;
  15. window._sequence = sequence;
  16. window._frameRate = 25;
  17. // window.OnChange.AddListener( callback );
  18. window.OnChange = callback;
  19. window.ShowAsDropDown( r, new Vector2(200, 100) );
  20. }
  21. // private ChangeFrameRateEvent OnChange = new ChangeFrameRateEvent();
  22. private UnityAction<FSequence, int, bool> OnChange = null;
  23. private FSequence _sequence;
  24. private int _frameRate;
  25. void OnGUI()
  26. {
  27. EditorGUIUtility.labelWidth = 70;
  28. _frameRate = EditorGUILayout.IntSlider( "Frame Rate", _frameRate, 1, 120 );
  29. GUILayout.Space( 10 );
  30. EditorGUILayout.LabelField( "New Length", (_sequence.Length*_sequence.InverseFrameRate*_frameRate).ToString());
  31. EditorGUIUtility.labelWidth = 0;
  32. GUILayout.FlexibleSpace();
  33. EditorGUILayout.BeginHorizontal();
  34. if( GUILayout.Button( "Cancel", GUILayout.Width(80) ) )
  35. Close();
  36. GUILayout.FlexibleSpace();
  37. if( GUILayout.Button( "Change", GUILayout.Width(80) ) )
  38. {
  39. OnChange.Invoke( _sequence, _frameRate, true );
  40. Close();
  41. }
  42. EditorGUILayout.EndHorizontal();
  43. }
  44. // private class ChangeFrameRateEvent : UnityEvent<FSequence, int, bool>
  45. // {
  46. // }
  47. }
  48. }