From 42dbfc88271d039e5ce97b4a4b006081e2aa20e7 Mon Sep 17 00:00:00 2001 From: Hubert Mattusch Date: Sun, 14 May 2023 01:00:03 +0200 Subject: [PATCH] popups + android build utils --- Editor/BuildingUtils.cs | 19 +++++++++++++++++++ Editor/ToolsWindowBase.cs | 23 +++++++++++++++-------- NEG/UI/Popup/PopupData.cs | 6 +++++- NEG/UI/UiManager.cs | 21 +++++++++++++++++---- NEG/UI/UnityUi/Buttons/ButtonReaction.cs | 4 ++-- 5 files changed, 58 insertions(+), 15 deletions(-) diff --git a/Editor/BuildingUtils.cs b/Editor/BuildingUtils.cs index fcf507e..b2acc8d 100644 --- a/Editor/BuildingUtils.cs +++ b/Editor/BuildingUtils.cs @@ -89,6 +89,25 @@ public static class BuildingUtils BuildWindows(true); } + [MenuItem("Tools/Build/Platform/Android/GooglePlay")] + public static void BuildGooglePlay() + { + IncreaseBuildNumber(); + PlayerSettings.Android.bundleVersionCode++; + EditorUserBuildSettings.buildAppBundle = true; + + var buildPlayerOptions = new BuildPlayerOptions { scenes = new string[EditorBuildSettings.scenes.Length] }; + for (int i = 0; i < EditorBuildSettings.scenes.Length; i++) + { + buildPlayerOptions.scenes[i] = EditorBuildSettings.scenes[i].path; + } + + buildPlayerOptions.target = BuildTarget.Android; + buildPlayerOptions.options = BuildOptions.None; + buildPlayerOptions.locationPathName = Application.dataPath + + $"/../../{Application.productName}-GooglePlay/{Application.productName}.aab"; + BuildPipeline.BuildPlayer(buildPlayerOptions); + } private static void BuildWindows(bool release) { diff --git a/Editor/ToolsWindowBase.cs b/Editor/ToolsWindowBase.cs index d200732..de000ad 100644 --- a/Editor/ToolsWindowBase.cs +++ b/Editor/ToolsWindowBase.cs @@ -34,14 +34,21 @@ namespace NegUtils.Editor EditorPrefs.SetBool("StartFromSceneIndex0", newVal); } - if (startFromSceneIndex0) + if (!startFromSceneIndex0) + return; + + bool goToCurrentScene = EditorPrefs.GetBool("GoToCurrentSceneAfterPlay"); + newVal = GUILayout.Toggle(goToCurrentScene, "Go to current scene after play"); + if (newVal != goToCurrentScene) { - bool goToCurrentScene = EditorPrefs.GetBool("GoToCurrentSceneAfterPlay"); - newVal = GUILayout.Toggle(goToCurrentScene, "Go to current scene after play"); - if (newVal != goToCurrentScene) - { - EditorPrefs.SetBool("GoToCurrentSceneAfterPlay", newVal); - } + EditorPrefs.SetBool("GoToCurrentSceneAfterPlay", newVal); + } + + bool goToFirstScene = EditorPrefs.GetBool("GoToFirstSceneAfterPlay"); + newVal = GUILayout.Toggle(goToFirstScene, "Go to scene with index 1 after play"); + if (newVal != goToFirstScene) + { + EditorPrefs.SetBool("GoToFirstSceneAfterPlay", newVal); } } @@ -90,7 +97,7 @@ namespace NegUtils.Editor if (EditorPrefs.GetBool("GoToCurrentSceneAfterPlay")) EditorSceneManager.LoadSceneInPlayMode(EditorPrefs.GetString("LastOpenedScenePath"), new LoadSceneParameters(LoadSceneMode.Single)); - else + else if (EditorPrefs.GetBool("GoToFirstSceneAfterPlay")) SceneManager.LoadScene(1); } break; diff --git a/NEG/UI/Popup/PopupData.cs b/NEG/UI/Popup/PopupData.cs index 6bf528a..9aa2462 100644 --- a/NEG/UI/Popup/PopupData.cs +++ b/NEG/UI/Popup/PopupData.cs @@ -45,6 +45,10 @@ namespace NEG.UI.Popup /// /// Invalidate popup, will automatically skip this popup /// - public virtual void Invalidate() => IsValid = false; + public virtual void Invalidate() + { + IsValid = false; + UiManager.Instance.RefreshPopups(); + } } } \ No newline at end of file diff --git a/NEG/UI/UiManager.cs b/NEG/UI/UiManager.cs index 6cdb2b4..0300324 100644 --- a/NEG/UI/UiManager.cs +++ b/NEG/UI/UiManager.cs @@ -123,6 +123,13 @@ namespace NEG.UI popupsToShow.Enqueue(data, priority); UpdatePopupsState(forceShow, priority, data); } + + public void RefreshPopups() + { + if(currentShownPopup.data is { IsValid: true }) + return; + UpdatePopupsState(false); + } protected void PopupClosed(PopupData data) { @@ -147,11 +154,17 @@ namespace NEG.UI ShowPopup(data, priority); return; } - - if(!popupsToShow.TryDequeue(out var d, out int p)) - return; - ShowPopup(d, p); + while (popupsToShow.TryDequeue(out var d, out int p)) + { + if(!d.IsValid) + continue; + ShowPopup(d, p); + return; + } + + currentShownPopup.data?.Hide(); + currentShownPopup.data = null; } private void ShowPopup(PopupData data, int priority) diff --git a/NEG/UI/UnityUi/Buttons/ButtonReaction.cs b/NEG/UI/UnityUi/Buttons/ButtonReaction.cs index 9e8bf17..1f30b1d 100644 --- a/NEG/UI/UnityUi/Buttons/ButtonReaction.cs +++ b/NEG/UI/UnityUi/Buttons/ButtonReaction.cs @@ -6,9 +6,9 @@ namespace NEG.UI.UnityUi.Buttons [RequireComponent(typeof(BaseButton))] public abstract class ButtonReaction : MonoBehaviour { - private void Awake() => GetComponent().OnButtonPressed += OnClicked; + protected virtual void Awake() => GetComponent().OnButtonPressed += OnClicked; - private void OnDestroy() => GetComponent().OnButtonPressed -= OnClicked; + protected virtual void OnDestroy() => GetComponent().OnButtonPressed -= OnClicked; protected abstract void OnClicked(); }