popups + android build utils

This commit is contained in:
Hubert Mattusch 2023-05-14 01:00:03 +02:00
parent 359b616be9
commit 42dbfc8827
5 changed files with 58 additions and 15 deletions

View File

@ -89,6 +89,25 @@ public static class BuildingUtils
BuildWindows(true); 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) private static void BuildWindows(bool release)
{ {

View File

@ -34,14 +34,21 @@ namespace NegUtils.Editor
EditorPrefs.SetBool("StartFromSceneIndex0", newVal); EditorPrefs.SetBool("StartFromSceneIndex0", newVal);
} }
if (startFromSceneIndex0) if (!startFromSceneIndex0)
{ return;
bool goToCurrentScene = EditorPrefs.GetBool("GoToCurrentSceneAfterPlay"); bool goToCurrentScene = EditorPrefs.GetBool("GoToCurrentSceneAfterPlay");
newVal = GUILayout.Toggle(goToCurrentScene, "Go to current scene after play"); newVal = GUILayout.Toggle(goToCurrentScene, "Go to current scene after play");
if (newVal != goToCurrentScene) 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")) if (EditorPrefs.GetBool("GoToCurrentSceneAfterPlay"))
EditorSceneManager.LoadSceneInPlayMode(EditorPrefs.GetString("LastOpenedScenePath"), EditorSceneManager.LoadSceneInPlayMode(EditorPrefs.GetString("LastOpenedScenePath"),
new LoadSceneParameters(LoadSceneMode.Single)); new LoadSceneParameters(LoadSceneMode.Single));
else else if (EditorPrefs.GetBool("GoToFirstSceneAfterPlay"))
SceneManager.LoadScene(1); SceneManager.LoadScene(1);
} }
break; break;

View File

@ -45,6 +45,10 @@ namespace NEG.UI.Popup
/// <summary> /// <summary>
/// Invalidate popup, <see cref="UiManager"/> will automatically skip this popup /// Invalidate popup, <see cref="UiManager"/> will automatically skip this popup
/// </summary> /// </summary>
public virtual void Invalidate() => IsValid = false; public virtual void Invalidate()
{
IsValid = false;
UiManager.Instance.RefreshPopups();
}
} }
} }

View File

@ -124,6 +124,13 @@ namespace NEG.UI
UpdatePopupsState(forceShow, priority, data); UpdatePopupsState(forceShow, priority, data);
} }
public void RefreshPopups()
{
if(currentShownPopup.data is { IsValid: true })
return;
UpdatePopupsState(false);
}
protected void PopupClosed(PopupData data) protected void PopupClosed(PopupData data)
{ {
if (currentShownPopup.data != data) if (currentShownPopup.data != data)
@ -148,10 +155,16 @@ namespace NEG.UI
return; return;
} }
if(!popupsToShow.TryDequeue(out var d, out int p)) while (popupsToShow.TryDequeue(out var d, out int p))
return; {
if(!d.IsValid)
continue;
ShowPopup(d, p); ShowPopup(d, p);
return;
}
currentShownPopup.data?.Hide();
currentShownPopup.data = null;
} }
private void ShowPopup(PopupData data, int priority) private void ShowPopup(PopupData data, int priority)

View File

@ -6,9 +6,9 @@ namespace NEG.UI.UnityUi.Buttons
[RequireComponent(typeof(BaseButton))] [RequireComponent(typeof(BaseButton))]
public abstract class ButtonReaction : MonoBehaviour public abstract class ButtonReaction : MonoBehaviour
{ {
private void Awake() => GetComponent<BaseButton>().OnButtonPressed += OnClicked; protected virtual void Awake() => GetComponent<BaseButton>().OnButtonPressed += OnClicked;
private void OnDestroy() => GetComponent<BaseButton>().OnButtonPressed -= OnClicked; protected virtual void OnDestroy() => GetComponent<BaseButton>().OnButtonPressed -= OnClicked;
protected abstract void OnClicked(); protected abstract void OnClicked();
} }