ui-system-fix #4
@ -27,6 +27,7 @@ namespace NEG.Utils
|
|||||||
action?.Invoke();
|
action?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ActionAfterEndOfFrame(this MonoBehaviour mono, Action action) => mono.StartCoroutine(ActionAtNextFrame(action));
|
||||||
public static IEnumerator ActionAfterEndOfFrame(Action action)
|
public static IEnumerator ActionAfterEndOfFrame(Action action)
|
||||||
{
|
{
|
||||||
yield return WaitForEndOfFrame;
|
yield return WaitForEndOfFrame;
|
||||||
|
|||||||
@ -55,7 +55,18 @@ public static class BuildingUtils
|
|||||||
BuildDevelopment();
|
BuildDevelopment();
|
||||||
UploadSteam();
|
UploadSteam();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[MenuItem("Tools/Build/Steam/Demo")]
|
||||||
|
public static void SteamDemo()
|
||||||
|
{
|
||||||
|
if(!CanBuild())
|
||||||
|
return;
|
||||||
|
|
||||||
|
IncreaseBuildNumber();
|
||||||
|
BuildDemo();
|
||||||
|
UploadSteam(true);
|
||||||
|
}
|
||||||
|
|
||||||
[MenuItem("Tools/Build/All Release")]
|
[MenuItem("Tools/Build/All Release")]
|
||||||
public static void BuildRelease()
|
public static void BuildRelease()
|
||||||
@ -63,6 +74,7 @@ public static class BuildingUtils
|
|||||||
if(!CanBuild())
|
if(!CanBuild())
|
||||||
return;
|
return;
|
||||||
BuildWindowsRelease();
|
BuildWindowsRelease();
|
||||||
|
BuildLinuxRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("Tools/Build/All Development")]
|
[MenuItem("Tools/Build/All Development")]
|
||||||
@ -72,6 +84,15 @@ public static class BuildingUtils
|
|||||||
return;
|
return;
|
||||||
BuildWindowsDevelopment();
|
BuildWindowsDevelopment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MenuItem("Tools/Build/All Demo")]
|
||||||
|
public static void BuildDemo()
|
||||||
|
{
|
||||||
|
if(!CanBuild())
|
||||||
|
return;
|
||||||
|
BuildWindows(true, new[] {"DEMO"});
|
||||||
|
BuildLinux(true, new[] {"DEMO"});
|
||||||
|
}
|
||||||
|
|
||||||
[MenuItem("Tools/Build/Platform/Windows/x64-Development")]
|
[MenuItem("Tools/Build/Platform/Windows/x64-Development")]
|
||||||
public static void BuildWindowsDevelopment()
|
public static void BuildWindowsDevelopment()
|
||||||
@ -88,6 +109,15 @@ public static class BuildingUtils
|
|||||||
return;
|
return;
|
||||||
BuildWindows(true);
|
BuildWindows(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MenuItem("Tools/Build/Platform/Linux/x64-Release")]
|
||||||
|
public static void BuildLinuxRelease()
|
||||||
|
{
|
||||||
|
if(!CanBuild())
|
||||||
|
return;
|
||||||
|
BuildLinux(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[MenuItem("Tools/Build/Platform/Android/GooglePlay")]
|
[MenuItem("Tools/Build/Platform/Android/GooglePlay")]
|
||||||
public static void BuildGooglePlay()
|
public static void BuildGooglePlay()
|
||||||
@ -109,7 +139,7 @@ public static class BuildingUtils
|
|||||||
BuildPipeline.BuildPlayer(buildPlayerOptions);
|
BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void BuildWindows(bool release)
|
private static void BuildWindows(bool release, string[] additionalDefines = default)
|
||||||
{
|
{
|
||||||
var buildPlayerOptions = new BuildPlayerOptions { scenes = new string[EditorBuildSettings.scenes.Length] };
|
var buildPlayerOptions = new BuildPlayerOptions { scenes = new string[EditorBuildSettings.scenes.Length] };
|
||||||
for (int i = 0; i < EditorBuildSettings.scenes.Length; i++)
|
for (int i = 0; i < EditorBuildSettings.scenes.Length; i++)
|
||||||
@ -117,12 +147,31 @@ public static class BuildingUtils
|
|||||||
buildPlayerOptions.scenes[i] = EditorBuildSettings.scenes[i].path;
|
buildPlayerOptions.scenes[i] = EditorBuildSettings.scenes[i].path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildPlayerOptions.extraScriptingDefines = additionalDefines;
|
||||||
|
|
||||||
buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
|
buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
|
||||||
buildPlayerOptions.options = release ? BuildOptions.None : BuildOptions.Development;
|
buildPlayerOptions.options = release ? BuildOptions.None : BuildOptions.Development;
|
||||||
buildPlayerOptions.locationPathName = Application.dataPath +
|
buildPlayerOptions.locationPathName = Application.dataPath +
|
||||||
$"/../../{Application.productName}-Steam/ContentBuilder/content/windows/{Application.productName}.exe";
|
$"/../../{Application.productName}-Steam/ContentBuilder/content/windows/{Application.productName}.exe";
|
||||||
BuildPipeline.BuildPlayer(buildPlayerOptions);
|
BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void BuildLinux(bool release, string[] additionalDefines = default)
|
||||||
|
{
|
||||||
|
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.extraScriptingDefines = additionalDefines;
|
||||||
|
|
||||||
|
buildPlayerOptions.target = BuildTarget.StandaloneLinux64;
|
||||||
|
buildPlayerOptions.options = release ? BuildOptions.None : BuildOptions.Development;
|
||||||
|
buildPlayerOptions.locationPathName = Application.dataPath +
|
||||||
|
$"/../../{Application.productName}-Steam/ContentBuilder/content/linux/{Application.productName}.x86_64";
|
||||||
|
BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||||
|
}
|
||||||
|
|
||||||
private static void IncreaseBuildNumber()
|
private static void IncreaseBuildNumber()
|
||||||
{
|
{
|
||||||
@ -135,9 +184,13 @@ public static class BuildingUtils
|
|||||||
PlayerSettings.bundleVersion = string.Join(".", versionParts);
|
PlayerSettings.bundleVersion = string.Join(".", versionParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UploadSteam()
|
private static void UploadSteam(bool demo = false)
|
||||||
{
|
{
|
||||||
string command = $"cd {Application.dataPath}/../../{Application.productName}-Steam/ContentBuilder && run_build.bat";
|
string command = $"cd {Application.dataPath}/../../{Application.productName}-Steam/ContentBuilder && push_build.bat";
|
||||||
|
if (demo)
|
||||||
|
{
|
||||||
|
command = $"cd {Application.dataPath}/../../{Application.productName}-Steam/ContentBuilder && push_demo.bat";
|
||||||
|
}
|
||||||
|
|
||||||
var processInfo = new ProcessStartInfo("cmd.exe", $"/c {command}")
|
var processInfo = new ProcessStartInfo("cmd.exe", $"/c {command}")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,6 +6,7 @@ using NEG.Utils;
|
|||||||
using NegUtils.NEG.UI;
|
using NegUtils.NEG.UI;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NEG.UI
|
namespace NEG.UI
|
||||||
@ -34,7 +35,7 @@ namespace NEG.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current window that is considered main (focused, lastly opened). Can be null.
|
/// Current window that is considered main (focused, lastly opened). Can be null.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IWindow CurrentMainWindow { get; protected set; }
|
public IWindow CurrentMainWindow => mainWindows.LastOrDefault();
|
||||||
|
|
||||||
public PopupData CurrentPopup => currentShownPopup.data;
|
public PopupData CurrentPopup => currentShownPopup.data;
|
||||||
|
|
||||||
@ -47,6 +48,8 @@ namespace NEG.UI
|
|||||||
//TODO: localize
|
//TODO: localize
|
||||||
private string localizedYes = "Yes", localizedNo = "No", localizedOk = "Ok";
|
private string localizedYes = "Yes", localizedNo = "No", localizedOk = "Ok";
|
||||||
|
|
||||||
|
private List<IWindow> mainWindows;
|
||||||
|
|
||||||
protected UiManager(IArea startArea)
|
protected UiManager(IArea startArea)
|
||||||
{
|
{
|
||||||
if (Instance != null)
|
if (Instance != null)
|
||||||
@ -58,6 +61,7 @@ namespace NEG.UI
|
|||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
CurrentArea = startArea;
|
CurrentArea = startArea;
|
||||||
|
mainWindows = new List<IWindow>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -146,16 +150,13 @@ namespace NEG.UI
|
|||||||
|
|
||||||
public virtual void Dispose() => Instance = null;
|
public virtual void Dispose() => Instance = null;
|
||||||
|
|
||||||
public void SetMainWindow(IWindow window) => CurrentMainWindow = window;
|
public void SetMainWindow(IWindow window) => mainWindows.Add(window);
|
||||||
|
|
||||||
public void OnWindowClosed(IWindow window)
|
public void MainWindowClosed(IWindow window) => mainWindows.Remove(window);
|
||||||
{
|
|
||||||
if(CurrentMainWindow != window)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//TODO: select new main window
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public void OnWindowClosed(IWindow window) => MainWindowClosed(window);
|
||||||
|
|
||||||
|
//TODO: select new main window
|
||||||
protected void PopupClosed(PopupData data)
|
protected void PopupClosed(PopupData data)
|
||||||
{
|
{
|
||||||
if (currentShownPopup.data != data)
|
if (currentShownPopup.data != data)
|
||||||
@ -169,7 +170,7 @@ namespace NEG.UI
|
|||||||
protected void SetDefaultPopup(IDefaultPopup popup) => currentDefaultPopup = popup;
|
protected void SetDefaultPopup(IDefaultPopup popup) => currentDefaultPopup = popup;
|
||||||
|
|
||||||
|
|
||||||
private void UpdatePopupsState(bool forceShow, int priority = 0, PopupData data = null)
|
protected virtual void UpdatePopupsState(bool forceShow, int priority = 0, PopupData data = null)
|
||||||
{
|
{
|
||||||
if (forceShow)
|
if (forceShow)
|
||||||
{
|
{
|
||||||
@ -183,6 +184,8 @@ namespace NEG.UI
|
|||||||
|
|
||||||
while (popupsToShow.TryDequeue(out var d, out int p))
|
while (popupsToShow.TryDequeue(out var d, out int p))
|
||||||
{
|
{
|
||||||
|
if(d == null)
|
||||||
|
continue;
|
||||||
if(!d.IsValid)
|
if(!d.IsValid)
|
||||||
continue;
|
continue;
|
||||||
if(d == currentShownPopup.data)
|
if(d == currentShownPopup.data)
|
||||||
|
|||||||
17
NEG/UI/UnityUi/Area/AutoOpenWindowWhenNoOther.cs
Normal file
17
NEG/UI/UnityUi/Area/AutoOpenWindowWhenNoOther.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using NEG.UI.UnityUi.Window;
|
||||||
|
using NEG.UI.Window;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NEG.UI.Area
|
||||||
|
{
|
||||||
|
public class AutoOpenWindowWhenNoOther : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private MonoWindow window;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
if(UiManager.Instance.CurrentMainWindow == null)
|
||||||
|
window.Open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
NEG/UI/UnityUi/Area/AutoOpenWindowWhenNoOther.cs.meta
Normal file
3
NEG/UI/UnityUi/Area/AutoOpenWindowWhenNoOther.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 473c065573984067a824ebf3b605c3ab
|
||||||
|
timeCreated: 1695048071
|
||||||
@ -12,7 +12,7 @@ namespace NEG.UI.Area
|
|||||||
protected override void OnBackUsed(IControllable.BackUsed backUsed)
|
protected override void OnBackUsed(IControllable.BackUsed backUsed)
|
||||||
{
|
{
|
||||||
base.OnBackUsed(backUsed);
|
base.OnBackUsed(backUsed);
|
||||||
UiManager.Instance.CurrentMainWindow.Close();
|
UiManager.Instance.CurrentMainWindow?.Close();
|
||||||
backUsed.Used = true;
|
backUsed.Used = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace NEG.UI.Area
|
|||||||
|
|
||||||
public void OpenWindow(IWindow window, object data = null) => DefaultWindowSlot.AttachWindow(window, data);
|
public void OpenWindow(IWindow window, object data = null) => DefaultWindowSlot.AttachWindow(window, data);
|
||||||
|
|
||||||
private void Awake()
|
protected virtual void Awake()
|
||||||
{
|
{
|
||||||
if (setAsDefaultArea)
|
if (setAsDefaultArea)
|
||||||
UiManager.Instance.CurrentArea = this;
|
UiManager.Instance.CurrentArea = this;
|
||||||
|
|||||||
@ -1,3 +1,11 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 39eb59ca1ef60934abb3f0c64169be65
|
guid: 39eb59ca1ef60934abb3f0c64169be65
|
||||||
timeCreated: 1670707479
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 10
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using KBCore.Refs;
|
using KBCore.Refs;
|
||||||
|
using NEG.UI.UnityUi.Window;
|
||||||
using NegUtils.NEG.UI;
|
using NegUtils.NEG.UI;
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -11,6 +12,8 @@ namespace NEG.UI.UnityUi
|
|||||||
|
|
||||||
[SerializeField, Self] protected InterfaceRef<IControllable> controllable;
|
[SerializeField, Self] protected InterfaceRef<IControllable> controllable;
|
||||||
|
|
||||||
|
protected MonoWindow ControllableAsWindow => (MonoWindow)controllable.Value;
|
||||||
|
|
||||||
protected virtual void Awake()
|
protected virtual void Awake()
|
||||||
{
|
{
|
||||||
controllable.Value.OnOpened += OnOpened;
|
controllable.Value.OnOpened += OnOpened;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using NEG.UI.UnityUi.Window;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
using UnityEngine.InputSystem.UI;
|
using UnityEngine.InputSystem.UI;
|
||||||
@ -11,16 +12,16 @@ namespace NEG.UI.UnityUi
|
|||||||
Direction
|
Direction
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UiInputModule { }
|
public class UiInputModule { public SelectionSource CurrentSelectionSource { get; protected set; }}
|
||||||
|
|
||||||
public class DefaultInputModule : UiInputModule
|
public class DefaultInputModule : UiInputModule
|
||||||
{
|
{
|
||||||
public SelectionSource CurrentSelectionSource { get; private set; }
|
|
||||||
|
|
||||||
public DefaultInputModule()
|
public DefaultInputModule()
|
||||||
{
|
{
|
||||||
var defaultActions = new DefaultInputActions();
|
var defaultActions = new DefaultInputActions();
|
||||||
InputActionReference.Create(defaultActions.UI.Navigate).action.performed += (ctx) => OnSelectionChangeStarted();
|
InputActionReference.Create(defaultActions.UI.Navigate).action.performed += (ctx) => OnSelectionChangeStarted();
|
||||||
|
InputActionReference.Create(defaultActions.UI.Cancel).action.performed +=
|
||||||
|
(_) => UiManager.Instance.UseBack();
|
||||||
defaultActions.Enable();
|
defaultActions.Enable();
|
||||||
|
|
||||||
if (Gamepad.current != null)
|
if (Gamepad.current != null)
|
||||||
@ -31,9 +32,9 @@ namespace NEG.UI.UnityUi
|
|||||||
//var keyboardAction = new InputAction(binding: "/<Keyboard>/*");
|
//var keyboardAction = new InputAction(binding: "/<Keyboard>/*");
|
||||||
//keyboardAction.performed += (context) => CurrentInputSource = EInputSource.Keyboard;
|
//keyboardAction.performed += (context) => CurrentInputSource = EInputSource.Keyboard;
|
||||||
//keyboardAction.Enable();
|
//keyboardAction.Enable();
|
||||||
var gamepadAction = new InputAction(binding: "/<Gamepad>/*");
|
//var gamepadAction = new InputAction(binding: "/<Gamepad>/*");
|
||||||
gamepadAction.performed += (context) => OnSelectionChangeStarted();
|
//gamepadAction.performed += (context) => OnSelectionChangeStarted();
|
||||||
gamepadAction.Enable();
|
//gamepadAction.Enable();
|
||||||
|
|
||||||
var mouseAction = new InputAction(binding: "/<Mouse>/*");
|
var mouseAction = new InputAction(binding: "/<Mouse>/*");
|
||||||
mouseAction.performed += (context) =>
|
mouseAction.performed += (context) =>
|
||||||
@ -47,15 +48,37 @@ namespace NEG.UI.UnityUi
|
|||||||
|
|
||||||
private void OnSelectionChangeStarted()
|
private void OnSelectionChangeStarted()
|
||||||
{
|
{
|
||||||
if(CurrentSelectionSource == SelectionSource.Direction)
|
if(CurrentSelectionSource == SelectionSource.Direction && EventSystem.current.currentSelectedGameObject != null)
|
||||||
return;
|
return;
|
||||||
SetDirectionInput();
|
SetDirectionInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetDirectionInput()
|
private void SetDirectionInput()
|
||||||
{
|
{
|
||||||
|
if (EventSystem.current == null || MonoUiManager.Instance == null )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
CurrentSelectionSource = SelectionSource.Direction;
|
CurrentSelectionSource = SelectionSource.Direction;
|
||||||
Cursor.visible = false;
|
Cursor.visible = false;
|
||||||
|
if (EventSystem.current.currentSelectedGameObject == null && MonoUiManager.Instance.CurrentMainWindow != null)
|
||||||
|
{
|
||||||
|
EventSystem.current.SetSelectedGameObject(((MonoWindow)MonoUiManager.Instance.CurrentMainWindow).DefaultSelectedItem);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var data = new PointerEventData(EventSystem.current);
|
||||||
|
var currentSelected = EventSystem.current.currentSelectedGameObject;
|
||||||
|
if (currentSelected != null)
|
||||||
|
{
|
||||||
|
for (var current = EventSystem.current.currentSelectedGameObject.transform;
|
||||||
|
current != null;
|
||||||
|
current = current.parent)
|
||||||
|
{
|
||||||
|
ExecuteEvents.Execute(current.gameObject, data, ExecuteEvents.pointerExitHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EventSystem.current.SetSelectedGameObject(currentSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPointerInput()
|
private void SetPointerInput()
|
||||||
@ -72,6 +95,8 @@ namespace NEG.UI.UnityUi
|
|||||||
if (EventSystem.current.currentInputModule == null)
|
if (EventSystem.current.currentInputModule == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
EventSystem.current.SetSelectedGameObject(null);
|
||||||
|
|
||||||
var module = (InputSystemUIInputModule)EventSystem.current.currentInputModule;
|
var module = (InputSystemUIInputModule)EventSystem.current.currentInputModule;
|
||||||
var result = module.GetLastRaycastResult(0);
|
var result = module.GetLastRaycastResult(0);
|
||||||
if(result.gameObject == null)
|
if(result.gameObject == null)
|
||||||
|
|||||||
@ -3,11 +3,13 @@ using NEG.UI.Popup;
|
|||||||
using NEG.UI.UnityUi.Buttons.Reaction;
|
using NEG.UI.UnityUi.Buttons.Reaction;
|
||||||
using NEG.UI.UnityUi.Buttons.Settings;
|
using NEG.UI.UnityUi.Buttons.Settings;
|
||||||
using NEG.UI.UnityUi.Popup;
|
using NEG.UI.UnityUi.Popup;
|
||||||
|
using NEG.UI.UnityUi.Window;
|
||||||
using NEG.Utils;
|
using NEG.Utils;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Assertions;
|
using UnityEngine.Assertions;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
@ -68,6 +70,20 @@ namespace NEG.UI.UnityUi
|
|||||||
Instance = null;
|
Instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void UpdatePopupsState(bool forceShow, int priority = 0, PopupData data = null)
|
||||||
|
{
|
||||||
|
base.UpdatePopupsState(forceShow, priority, data);
|
||||||
|
if(inputModule.CurrentSelectionSource != SelectionSource.Direction)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (CurrentPopup == null && (EventSystem.current.currentSelectedGameObject == null || !EventSystem.current.currentSelectedGameObject.activeInHierarchy))
|
||||||
|
{
|
||||||
|
if(((MonoWindow)CurrentMainWindow).DefaultSelectedItem == null)
|
||||||
|
return;
|
||||||
|
EventSystem.current.SetSelectedGameObject(((MonoWindow)CurrentMainWindow).DefaultSelectedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SpawnDefaultPopup()
|
private void SpawnDefaultPopup()
|
||||||
{
|
{
|
||||||
var canvas = Object.Instantiate(canvasPrefab);
|
var canvas = Object.Instantiate(canvasPrefab);
|
||||||
|
|||||||
@ -12,6 +12,7 @@ using UnityEngine.Serialization;
|
|||||||
|
|
||||||
namespace NEG.UI.UnityUi.Window
|
namespace NEG.UI.UnityUi.Window
|
||||||
{
|
{
|
||||||
|
[DefaultExecutionOrder(10)]
|
||||||
public class MonoWindow : MonoBehaviour, IWindow
|
public class MonoWindow : MonoBehaviour, IWindow
|
||||||
{
|
{
|
||||||
public event Action<object> OnOpened;
|
public event Action<object> OnOpened;
|
||||||
@ -22,8 +23,11 @@ namespace NEG.UI.UnityUi.Window
|
|||||||
public IWindowSlot Parent { get; private set; }
|
public IWindowSlot Parent { get; private set; }
|
||||||
|
|
||||||
public bool IsMainWindow { get; private set; }
|
public bool IsMainWindow { get; private set; }
|
||||||
|
|
||||||
|
public bool IsOpened { get; protected set; }
|
||||||
|
|
||||||
private IWindowSlot DefaultWindowSlot => windowSlots[0];
|
private IWindowSlot DefaultWindowSlot => windowSlots[0];
|
||||||
|
public GameObject DefaultSelectedItem => defaultSelectedItem;
|
||||||
|
|
||||||
[SerializeField] private List<MonoWindowSlot> windowSlots;
|
[SerializeField] private List<MonoWindowSlot> windowSlots;
|
||||||
|
|
||||||
@ -32,6 +36,7 @@ namespace NEG.UI.UnityUi.Window
|
|||||||
public void SetOpenedState(IWindowSlot parentSlot, object data)
|
public void SetOpenedState(IWindowSlot parentSlot, object data)
|
||||||
{
|
{
|
||||||
gameObject.SetActive(true);
|
gameObject.SetActive(true);
|
||||||
|
IsOpened = true;
|
||||||
Parent = parentSlot;
|
Parent = parentSlot;
|
||||||
EventSystem.current.SetSelectedGameObject(defaultSelectedItem);
|
EventSystem.current.SetSelectedGameObject(defaultSelectedItem);
|
||||||
if (parentSlot.OpenWindowAsMain)
|
if (parentSlot.OpenWindowAsMain)
|
||||||
@ -42,6 +47,7 @@ namespace NEG.UI.UnityUi.Window
|
|||||||
public void SetClosedState()
|
public void SetClosedState()
|
||||||
{
|
{
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
|
IsOpened = false;
|
||||||
Parent = null;
|
Parent = null;
|
||||||
((ISlotsHolder)this).CloseAllWindows();
|
((ISlotsHolder)this).CloseAllWindows();
|
||||||
UiManager.Instance.OnWindowClosed(this);
|
UiManager.Instance.OnWindowClosed(this);
|
||||||
@ -54,6 +60,14 @@ namespace NEG.UI.UnityUi.Window
|
|||||||
|
|
||||||
private void Awake() => ((IWindow)this).SetHiddenState();
|
private void Awake() => ((IWindow)this).SetHiddenState();
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
if (IsOpened)
|
||||||
|
{
|
||||||
|
UiManager.Instance.OnWindowClosed(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnValidate()
|
private void OnValidate()
|
||||||
{
|
{
|
||||||
#if !NEG_UI_DISABLE_WARNING_DEFAULT_SELECTION
|
#if !NEG_UI_DISABLE_WARNING_DEFAULT_SELECTION
|
||||||
|
|||||||
@ -1,3 +1,11 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 85d136d6850728d4b96c26fa286ffe3c
|
guid: 85d136d6850728d4b96c26fa286ffe3c
|
||||||
timeCreated: 1670709296
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 11
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|||||||
13
NEG/UI/UnityUi/Window/NoReactionOnBack.cs
Normal file
13
NEG/UI/UnityUi/Window/NoReactionOnBack.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using NegUtils.NEG.UI;
|
||||||
|
|
||||||
|
namespace NEG.UI.UnityUi.Window
|
||||||
|
{
|
||||||
|
public class NoReactionOnBack : MonoController
|
||||||
|
{
|
||||||
|
protected override void OnBackUsed(IControllable.BackUsed backUsed)
|
||||||
|
{
|
||||||
|
base.OnBackUsed(backUsed);
|
||||||
|
backUsed.Used = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
NEG/UI/UnityUi/Window/NoReactionOnBack.cs.meta
Normal file
3
NEG/UI/UnityUi/Window/NoReactionOnBack.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c4a5380c95244c76ac79f820d16ea11c
|
||||||
|
timeCreated: 1702565120
|
||||||
@ -24,7 +24,13 @@ namespace NEG.UI.WindowSlot
|
|||||||
window.SetOpenedState(this, data);
|
window.SetOpenedState(this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DetachWindow(IWindow window) => CurrentWindow = null;
|
public override void DetachWindow(IWindow window)
|
||||||
|
{
|
||||||
|
if(UiManager.Instance.CurrentMainWindow == window)
|
||||||
|
UiManager.Instance.MainWindowClosed(window);
|
||||||
|
CurrentWindow = null;
|
||||||
|
}
|
||||||
|
|
||||||
public override void CloseAllWindows() => CurrentWindow = null;
|
public override void CloseAllWindows() => CurrentWindow = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,7 +1,10 @@
|
|||||||
using NEG.UI.UnityUi.WindowSlot;
|
using NEG.UI;
|
||||||
|
using NEG.UI.UnityUi.Window;
|
||||||
|
using NEG.UI.UnityUi.WindowSlot;
|
||||||
using NEG.UI.Window;
|
using NEG.UI.Window;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace NegUtils.NEG.UI.UnityUi.WindowSlot
|
namespace NegUtils.NEG.UI.UnityUi.WindowSlot
|
||||||
{
|
{
|
||||||
@ -41,8 +44,11 @@ namespace NegUtils.NEG.UI.UnityUi.WindowSlot
|
|||||||
window.SetClosedState();
|
window.SetClosedState();
|
||||||
windowsHistory.Remove(window);
|
windowsHistory.Remove(window);
|
||||||
if (window != currentWindow || windowsHistory.Count == 0) return;
|
if (window != currentWindow || windowsHistory.Count == 0) return;
|
||||||
windowsHistory[^1].SeVisibleState();
|
|
||||||
currentWindow = windowsHistory[^1];
|
currentWindow = windowsHistory[^1];
|
||||||
|
currentWindow.SeVisibleState();
|
||||||
|
if(UiManager.Instance.CurrentMainWindow == window)
|
||||||
|
UiManager.Instance.MainWindowClosed(window);
|
||||||
|
EventSystem.current.SetSelectedGameObject(((MonoWindow)currentWindow).DefaultSelectedItem);
|
||||||
}
|
}
|
||||||
public override void CloseAllWindows()
|
public override void CloseAllWindows()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user