HotReloadEventPopup.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using UnityEngine;
  2. using UnityEditor;
  3. namespace SingularityGroup.HotReload.Editor {
  4. public enum PopupSource {
  5. Window,
  6. Overlay,
  7. }
  8. public class HotReloadEventPopup : PopupWindowContent {
  9. public static HotReloadEventPopup I = new HotReloadEventPopup();
  10. private Vector2 _PopupScrollPos;
  11. public bool open { get; private set; }
  12. private PopupSource source;
  13. private HotReloadRunTabState currentState;
  14. public static void Open(PopupSource source, Vector2 pos) {
  15. I.source = source;
  16. PopupWindow.Show(new Rect(pos.x, pos.y, 0, 0), I);
  17. }
  18. public override Vector2 GetWindowSize() {
  19. if (HotReloadRunTab.ShouldRenderConsumption(currentState)
  20. && (HotReloadWindowStyles.windowScreenWidth <= Constants.ConsumptionsHideWidth
  21. || HotReloadWindowStyles.windowScreenHeight <= Constants.ConsumptionsHideHeight
  22. || source == PopupSource.Overlay)
  23. ) {
  24. return new Vector2(600, 450);
  25. } else {
  26. return new Vector2(500, 375);
  27. }
  28. }
  29. public void Repaint() {
  30. if (open) {
  31. PopupWindow.GetWindow<PopupWindow>().Repaint();
  32. }
  33. }
  34. public override void OnGUI(Rect rect) {
  35. if (Event.current.type == EventType.Layout) {
  36. currentState = HotReloadRunTabState.Current;
  37. }
  38. if (HotReloadWindowStyles.windowScreenWidth <= Constants.UpgradeLicenseNoteHideWidth
  39. || HotReloadWindowStyles.windowScreenHeight <= Constants.UpgradeLicenseNoteHideHeight
  40. || source == PopupSource.Overlay
  41. ) {
  42. HotReloadRunTab.RenderUpgradeLicenseNote(currentState, HotReloadWindowStyles.UpgradeLicenseButtonOverlayStyle);
  43. }
  44. using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) {
  45. using (var scope = new EditorGUILayout.ScrollViewScope(_PopupScrollPos, GUIStyle.none, GUI.skin.verticalScrollbar, GUILayout.MaxHeight(495))) {
  46. _PopupScrollPos.x = scope.scrollPosition.x;
  47. _PopupScrollPos.y = scope.scrollPosition.y;
  48. if (HotReloadWindowStyles.windowScreenWidth <= Constants.ConsumptionsHideWidth
  49. || HotReloadWindowStyles.windowScreenHeight <= Constants.ConsumptionsHideHeight
  50. || source == PopupSource.Overlay
  51. ) {
  52. HotReloadRunTab.RenderLicenseInfo(currentState);
  53. }
  54. HotReloadRunTab.RenderBars(currentState);
  55. }
  56. }
  57. bool rateAppShown = HotReloadWindow.ShouldShowRateApp();
  58. if ((HotReloadWindowStyles.windowScreenWidth <= Constants.RateAppHideWidth
  59. || HotReloadWindowStyles.windowScreenHeight <= Constants.RateAppHideHeight
  60. || source == PopupSource.Overlay)
  61. && rateAppShown
  62. ) {
  63. HotReloadWindow.RenderRateApp();
  64. }
  65. if (HotReloadWindowStyles.windowScreenWidth <= Constants.EventFiltersShownHideWidth
  66. || source == PopupSource.Overlay
  67. ) {
  68. using (new EditorGUILayout.HorizontalScope()) {
  69. GUILayout.Space(21);
  70. HotReloadTimelineHelper.RenderAlertFilters();
  71. }
  72. }
  73. HotReloadState.ShowingRedDot = false;
  74. }
  75. public override void OnOpen() {
  76. open = true;
  77. }
  78. public override void OnClose() {
  79. _PopupScrollPos = Vector2.zero;
  80. open = false;
  81. }
  82. }
  83. }