From 481b1617000df8ae0c520666cf49be182b79eb78 Mon Sep 17 00:00:00 2001 From: Tr0sT Date: Wed, 19 Aug 2020 10:23:12 +0300 Subject: [PATCH] feat: c#8 and WindowsManager events --- .../Runtime/UtilityManagers/BackButtonEventManager.cs | 5 +++-- .../Runtime/UtilityManagers/OrientationEventManager.cs | 5 +++-- Assets/com.nuclearband.windowsmanager/Runtime/Window.cs | 1 + .../Runtime/WindowPredicates.cs | 1 + .../Runtime/WindowReference.cs | 3 ++- .../Runtime/WindowsManager.cs | 7 ++++++- .../Runtime/WindowsManagerSettings.cs | 3 ++- .../Samples/Sample/Example1/Example1.cs | 3 ++- .../Samples/Sample/Example1/Example1Window1.cs | 1 + .../Samples/Sample/Example1/Example1Window2.cs | 5 +++-- .../Samples/Sample/Example2/Example2.cs | 5 +++-- .../Samples/Sample/Example2/Example2Window1.cs | 3 ++- .../Samples/Sample/Example2/Example2Window2.cs | 5 +++-- .../Samples/Sample/Example3/Example3.cs | 5 +++-- .../Samples/Sample/Example3/Example3Window1.cs | 3 ++- .../Samples/Sample/Example3/Example3Window2.cs | 5 +++-- .../Samples/Sample/Example4/Example4.cs | 5 +++-- .../Samples/Sample/Example4/Example4Window1.cs | 3 ++- .../Samples/Sample/Example4/Example4Window2.cs | 3 ++- 19 files changed, 47 insertions(+), 24 deletions(-) diff --git a/Assets/com.nuclearband.windowsmanager/Runtime/UtilityManagers/BackButtonEventManager.cs b/Assets/com.nuclearband.windowsmanager/Runtime/UtilityManagers/BackButtonEventManager.cs index cd4046d..10987bf 100644 --- a/Assets/com.nuclearband.windowsmanager/Runtime/UtilityManagers/BackButtonEventManager.cs +++ b/Assets/com.nuclearband.windowsmanager/Runtime/UtilityManagers/BackButtonEventManager.cs @@ -1,4 +1,5 @@ -using System; +#nullable enable +using System; using UnityEngine; namespace NuclearBand @@ -19,4 +20,4 @@ private void Update() OnBackButtonPressed?.Invoke(); } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Runtime/UtilityManagers/OrientationEventManager.cs b/Assets/com.nuclearband.windowsmanager/Runtime/UtilityManagers/OrientationEventManager.cs index 4d3973a..989e99d 100644 --- a/Assets/com.nuclearband.windowsmanager/Runtime/UtilityManagers/OrientationEventManager.cs +++ b/Assets/com.nuclearband.windowsmanager/Runtime/UtilityManagers/OrientationEventManager.cs @@ -1,4 +1,5 @@ -using System; +#nullable enable +using System; using UnityEngine; namespace NuclearBand @@ -60,4 +61,4 @@ private DeviceScreenOrientation CalculateOrientation() return DeviceScreenOrientation.Portrait; } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Runtime/Window.cs b/Assets/com.nuclearband.windowsmanager/Runtime/Window.cs index 363a1b1..21671db 100644 --- a/Assets/com.nuclearband.windowsmanager/Runtime/Window.cs +++ b/Assets/com.nuclearband.windowsmanager/Runtime/Window.cs @@ -1,3 +1,4 @@ +#nullable enable using System; using UnityEngine; diff --git a/Assets/com.nuclearband.windowsmanager/Runtime/WindowPredicates.cs b/Assets/com.nuclearband.windowsmanager/Runtime/WindowPredicates.cs index 3cf3b38..9c77c95 100644 --- a/Assets/com.nuclearband.windowsmanager/Runtime/WindowPredicates.cs +++ b/Assets/com.nuclearband.windowsmanager/Runtime/WindowPredicates.cs @@ -1,3 +1,4 @@ +#nullable enable using UnityEngine; namespace NuclearBand diff --git a/Assets/com.nuclearband.windowsmanager/Runtime/WindowReference.cs b/Assets/com.nuclearband.windowsmanager/Runtime/WindowReference.cs index 0eeed3e..c4281cd 100644 --- a/Assets/com.nuclearband.windowsmanager/Runtime/WindowReference.cs +++ b/Assets/com.nuclearband.windowsmanager/Runtime/WindowReference.cs @@ -1,3 +1,4 @@ +#nullable enable namespace NuclearBand { public class WindowReference @@ -17,4 +18,4 @@ private void OnInitAfterRebuildCallback(Window window) Window.OnInitAfterRebuild += OnInitAfterRebuildCallback; } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Runtime/WindowsManager.cs b/Assets/com.nuclearband.windowsmanager/Runtime/WindowsManager.cs index 1dc117b..d25c710 100644 --- a/Assets/com.nuclearband.windowsmanager/Runtime/WindowsManager.cs +++ b/Assets/com.nuclearband.windowsmanager/Runtime/WindowsManager.cs @@ -1,3 +1,4 @@ +#nullable enable using UnityEngine; using System.Collections.Generic; using System; @@ -21,6 +22,8 @@ public WindowBuildData(string windowPath, string suffix, Action? setupWi } } + public static event Action? OnWindowCreated; + public static event Action? OnWindowClosed; public static bool InputBlocked { get; private set; } public static GameObject InputBlockPrefab { get; private set; } = null!; @@ -65,6 +68,7 @@ public static WindowReference CreateWindow(string windowPath, Action? se window.Init(); window.Show(); + OnWindowCreated?.Invoke(window); return windowReference; } @@ -244,6 +248,7 @@ private static void WindowOnHidden(Window window) windows.RemoveAt(i); windowBuildDataList.RemoveAt(i); + OnWindowClosed?.Invoke(window); return; } } @@ -268,4 +273,4 @@ private static void WindowOnCloseForRebuild(Window window) } } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Runtime/WindowsManagerSettings.cs b/Assets/com.nuclearband.windowsmanager/Runtime/WindowsManagerSettings.cs index da086ee..d455864 100644 --- a/Assets/com.nuclearband.windowsmanager/Runtime/WindowsManagerSettings.cs +++ b/Assets/com.nuclearband.windowsmanager/Runtime/WindowsManagerSettings.cs @@ -1,4 +1,5 @@ -using System; +#nullable enable +using System; using System.Collections.Generic; namespace NuclearBand diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1.cs index a3cedb8..0aa7c10 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1.cs @@ -1,3 +1,4 @@ +#nullable enable using UnityEngine; namespace NuclearBand @@ -15,4 +16,4 @@ void Start() WindowsManager.CreateWindow(Example1Window1.Path); } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1Window1.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1Window1.cs index c594412..43b0c4d 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1Window1.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1Window1.cs @@ -1,3 +1,4 @@ +#nullable enable using UnityEngine.UI; namespace NuclearBand diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1Window2.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1Window2.cs index fb9ed3a..fd9b6ac 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1Window2.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example1/Example1Window2.cs @@ -1,4 +1,5 @@ -using UnityEngine.UI; +#nullable enable +using UnityEngine.UI; namespace NuclearBand { @@ -19,4 +20,4 @@ public static WindowReference CreateWindow(string path, string title) return WindowsManager.CreateWindow(path, window => (window as Example1Window2)!.title = title); } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2.cs index 0fe06ba..6ec6539 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2.cs @@ -1,4 +1,5 @@ -using UnityEngine; +#nullable enable +using UnityEngine; namespace NuclearBand { @@ -15,4 +16,4 @@ private void Start() WindowsManager.CreateWindow(Example2Window1.Path); } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2Window1.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2Window1.cs index 4afd6f7..94d7904 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2Window1.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2Window1.cs @@ -1,4 +1,5 @@ -namespace NuclearBand +#nullable enable +namespace NuclearBand { public class Example2Window1 : Example1Window1 { diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2Window2.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2Window2.cs index 5e79e04..675a96f 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2Window2.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example2/Example2Window2.cs @@ -1,4 +1,5 @@ -using System.Collections; +#nullable enable +using System.Collections; using UnityEngine; namespace NuclearBand @@ -48,4 +49,4 @@ protected override void DeInit() canvasGroup.alpha = 1.0f; } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3.cs index f0552ec..45ca074 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3.cs @@ -1,4 +1,5 @@ -using System; +#nullable enable +using System; using System.Collections.Generic; using UnityEngine; @@ -22,4 +23,4 @@ void Start() WindowsManager.CreateWindow(Example3Window1.Path); } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3Window1.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3Window1.cs index 3a3b3a7..a90c3e1 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3Window1.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3Window1.cs @@ -1,4 +1,5 @@ - +#nullable enable + namespace NuclearBand { public class Example3Window1 : Example2Window1 diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3Window2.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3Window2.cs index b2f490c..638e232 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3Window2.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example3/Example3Window2.cs @@ -1,4 +1,5 @@ -using UnityEngine.UI; +#nullable enable +using UnityEngine.UI; namespace NuclearBand { @@ -49,4 +50,4 @@ void DrawRebuildNum() rebuildText.text = rebuildNum.ToString(); } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4.cs index fa31a80..12d65f4 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4.cs @@ -1,4 +1,5 @@ -using UnityEngine; +#nullable enable +using UnityEngine; namespace NuclearBand { @@ -15,4 +16,4 @@ void Start() WindowsManager.CreateWindow(Example4Window1.Path); } } -} \ No newline at end of file +} diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4Window1.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4Window1.cs index bcccbe1..289a8bb 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4Window1.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4Window1.cs @@ -1,4 +1,5 @@ -namespace NuclearBand +#nullable enable +namespace NuclearBand { public class Example4Window1 : Window { diff --git a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4Window2.cs b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4Window2.cs index 927a1d5..6290a91 100644 --- a/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4Window2.cs +++ b/Assets/com.nuclearband.windowsmanager/Samples/Sample/Example4/Example4Window2.cs @@ -1,4 +1,5 @@ -using System; +#nullable enable +using System; using UnityEngine; using UnityEngine.UI; using Random = UnityEngine.Random;