diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Modal/Modal.cs b/Assets/UnityScreenNavigator/Runtime/Core/Modal/Modal.cs index 04d15ac..f98fd48 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Modal/Modal.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Modal/Modal.cs @@ -323,6 +323,12 @@ internal void AfterExit(bool push, Modal partnerModal) IsTransitioning = false; TransitionAnimationType = null; } + + internal void BeforeReleaseAndForget() + { + foreach (var lifecycleEvent in _lifecycleEvents) + lifecycleEvent.Cleanup(); + } internal AsyncProcessHandle BeforeRelease() { diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Modal/ModalContainer.cs b/Assets/UnityScreenNavigator/Runtime/Core/Modal/ModalContainer.cs index f06a7e6..43f16dc 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Modal/ModalContainer.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Modal/ModalContainer.cs @@ -30,7 +30,7 @@ public sealed class ModalContainer : MonoBehaviour private readonly Dictionary> _assetLoadHandles = new Dictionary>(); - private readonly List _backdrops = new List(); + public List Backdrops { get; } = new List(); private readonly List _callbackReceivers = new List(); @@ -100,6 +100,8 @@ private void OnDestroy() var modal = _modals[modalId]; var assetLoadHandle = _assetLoadHandles[modalId]; + if (UnityScreenNavigatorSettings.Instance.CallCleanupWhenDestroy) + modal.BeforeReleaseAndForget(); Destroy(modal.gameObject); AssetLoader.Release(assetLoadHandle); } @@ -304,7 +306,7 @@ private IEnumerator PushRoutine(Type modalType, string resourceKey, bool playAni var backdrop = Instantiate(_backdropPrefab); backdrop.Setup((RectTransform)transform); - _backdrops.Add(backdrop); + Backdrops.Add(backdrop); var instance = Instantiate(assetLoadHandle.Result); if (!instance.TryGetComponent(modalType, out var c)) @@ -425,7 +427,7 @@ private IEnumerator PopRoutine(bool playAnimation, int popCount = 1) var unusedModalId = _orderedModalIds[i]; unusedModalIds.Add(unusedModalId); unusedModals.Add(_modals[unusedModalId]); - unusedBackdrops.Add(_backdrops[i]); + unusedBackdrops.Add(Backdrops[i]); } var enterModalIndex = _orderedModalIds.Count - popCount - 1; @@ -495,7 +497,7 @@ private IEnumerator PopRoutine(bool playAnimation, int popCount = 1) foreach (var unusedBackdrop in unusedBackdrops) { - _backdrops.Remove(unusedBackdrop); + Backdrops.Remove(unusedBackdrop); Destroy(unusedBackdrop.gameObject); } diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Page/Page.cs b/Assets/UnityScreenNavigator/Runtime/Core/Page/Page.cs index 773f6f4..e48e473 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Page/Page.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Page/Page.cs @@ -330,6 +330,12 @@ internal void AfterExit(bool push, Page partnerPage) IsTransitioning = false; TransitionAnimationType = null; } + + internal void BeforeReleaseAndForget() + { + foreach (var lifecycleEvent in _lifecycleEvents) + lifecycleEvent.Cleanup(); + } internal AsyncProcessHandle BeforeRelease() { diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Page/PageContainer.cs b/Assets/UnityScreenNavigator/Runtime/Core/Page/PageContainer.cs index 9403735..cd37a84 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Page/PageContainer.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Page/PageContainer.cs @@ -93,6 +93,8 @@ private void OnDestroy() var page = _pages[pageId]; var assetLoadHandle = _assetLoadHandles[pageId]; + if (UnityScreenNavigatorSettings.Instance.CallCleanupWhenDestroy) + page.BeforeReleaseAndForget(); Destroy(page.gameObject); AssetLoader.Release(assetLoadHandle); } diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Shared/UnityScreenNavigatorSettings.cs b/Assets/UnityScreenNavigator/Runtime/Core/Shared/UnityScreenNavigatorSettings.cs index 7ab5cd5..3f6b6f0 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Shared/UnityScreenNavigatorSettings.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Shared/UnityScreenNavigatorSettings.cs @@ -45,6 +45,8 @@ internal sealed class UnityScreenNavigatorSettings : ScriptableObject [EnabledIf(nameof(_enableInteractionInTransition), false)] [SerializeField] private bool _controlInteractionsOfAllContainers = true; + + [SerializeField] private bool _callCleanupWhenDestroy = true; private IAssetLoader _defaultAssetLoader; private ModalBackdrop _defaultModalBackdrop; @@ -191,6 +193,12 @@ public ITransitionAnimation GetDefaultSheetTransitionAnimation(bool enter) { return enter ? SheetEnterAnimation : SheetExitAnimation; } + + public bool CallCleanupWhenDestroy + { + get => _callCleanupWhenDestroy; + set => _callCleanupWhenDestroy = value; + } #if UNITY_EDITOR diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Sheet/Sheet.cs b/Assets/UnityScreenNavigator/Runtime/Core/Sheet/Sheet.cs index ff530be..56d62a8 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Sheet/Sheet.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Sheet/Sheet.cs @@ -282,10 +282,10 @@ internal void AfterExit(Sheet partnerSheet) TransitionAnimationType = null; } - internal AsyncProcessHandle BeforeRelease() + internal void BeforeReleaseAndForget() { - // Evaluate here because users may add/remove lifecycle events within the lifecycle events. - return CoroutineManager.Instance.Run(CreateCoroutine(_lifecycleEvents.Select(x => x.Cleanup()).ToArray())); + foreach (var lifecycleEvent in _lifecycleEvents) + lifecycleEvent.Cleanup(); } #if USN_USE_ASYNC_METHODS diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Sheet/SheetContainer.cs b/Assets/UnityScreenNavigator/Runtime/Core/Sheet/SheetContainer.cs index f900c02..994e496 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Sheet/SheetContainer.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Sheet/SheetContainer.cs @@ -448,7 +448,11 @@ private IEnumerator HideRoutine(bool playAnimation) public void UnregisterAll() { foreach (var sheet in _sheets.Values) + { + if (UnityScreenNavigatorSettings.Instance.CallCleanupWhenDestroy) + sheet.BeforeReleaseAndForget(); Destroy(sheet.gameObject); + } foreach (var assetLoadHandle in _assetLoadHandles.Values) AssetLoader.Release(assetLoadHandle); diff --git a/Assets/UnityScreenNavigator/package.json b/Assets/UnityScreenNavigator/package.json index 5f38263..222c6cc 100644 --- a/Assets/UnityScreenNavigator/package.json +++ b/Assets/UnityScreenNavigator/package.json @@ -2,7 +2,7 @@ "name": "com.harumak.unityscreennavigator", "displayName": "UnityScreenNavigator", "version": "1.6.5", - "unity": "2019.4", + "unity": "2021.3", "license": "MIT", "dependencies": { }, diff --git a/Packages/manifest.json b/Packages/manifest.json index c8a6ac1..cfad260 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -4,14 +4,14 @@ "com.harumak.unityuiplayables": "https://github.com/Haruma-K/UnityUIPlayables.git?path=/Assets/UnityUIPlayables", "com.neuecc.unirx": "https://github.com/neuecc/UniRx.git?path=Assets/Plugins/UniRx/Scripts", "com.unity.2d.sprite": "1.0.0", - "com.unity.addressables": "1.17.17", - "com.unity.collab-proxy": "1.6.0", - "com.unity.ide.rider": "1.2.1", - "com.unity.ide.visualstudio": "2.0.9", - "com.unity.ide.vscode": "1.2.3", - "com.unity.test-framework": "1.1.27", - "com.unity.textmeshpro": "2.1.6", - "com.unity.timeline": "1.2.18", + "com.unity.addressables": "1.19.19", + "com.unity.collab-proxy": "2.0.4", + "com.unity.ide.rider": "3.0.21", + "com.unity.ide.visualstudio": "2.0.18", + "com.unity.ide.vscode": "1.2.5", + "com.unity.test-framework": "1.1.31", + "com.unity.textmeshpro": "3.0.6", + "com.unity.timeline": "1.6.5", "com.unity.ugui": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 7ba2350..37449f2 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -5,7 +5,7 @@ "depth": 0, "source": "git", "dependencies": {}, - "hash": "73d86259ce31ce7f4dfe1d028ea1c3edf96c23e4" + "hash": "66de0d3a58b256b6e0194f285cc530fd0c08407b" }, "com.harumak.unityuiplayables": { "version": "https://github.com/Haruma-K/UnityUIPlayables.git?path=/Assets/UnityUIPlayables", @@ -15,14 +15,14 @@ "com.unity.textmeshpro": "2.0.1", "com.unity.timeline": "1.2.14" }, - "hash": "799efe48dc0a6990e8a1d7a2372415a11fa8dfbc" + "hash": "e61ba2931c7d57926098254e61df7d51488782e6" }, "com.neuecc.unirx": { "version": "https://github.com/neuecc/UniRx.git?path=Assets/Plugins/UniRx/Scripts", "depth": 0, "source": "git", "dependencies": {}, - "hash": "284d5c50d3f1ddd9fa7df3d382ea904732a9c2ff" + "hash": "7cce378b3f8c8943b4cac8e847bdbb8e2e1802d1" }, "com.unity.2d.sprite": { "version": "1.0.0", @@ -31,11 +31,11 @@ "dependencies": {} }, "com.unity.addressables": { - "version": "1.17.17", + "version": "1.19.19", "depth": 0, "source": "registry", "dependencies": { - "com.unity.scriptablebuildpipeline": "1.17.0", + "com.unity.scriptablebuildpipeline": "1.19.6", "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.imageconversion": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0", @@ -45,7 +45,7 @@ "url": "https://packages.unity.com" }, "com.unity.collab-proxy": { - "version": "1.6.0", + "version": "2.0.4", "depth": 0, "source": "registry", "dependencies": {}, @@ -59,16 +59,16 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "1.2.1", + "version": "3.0.21", "depth": 0, "source": "registry", "dependencies": { - "com.unity.test-framework": "1.1.1" + "com.unity.ext.nunit": "1.0.6" }, "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.9", + "version": "2.0.18", "depth": 0, "source": "registry", "dependencies": { @@ -77,21 +77,21 @@ "url": "https://packages.unity.com" }, "com.unity.ide.vscode": { - "version": "1.2.3", + "version": "1.2.5", "depth": 0, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.scriptablebuildpipeline": { - "version": "1.17.0", + "version": "1.20.1", "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.test-framework": { - "version": "1.1.27", + "version": "1.1.31", "depth": 0, "source": "registry", "dependencies": { @@ -102,7 +102,7 @@ "url": "https://packages.unity.com" }, "com.unity.textmeshpro": { - "version": "2.1.6", + "version": "3.0.6", "depth": 0, "source": "registry", "dependencies": { @@ -111,7 +111,7 @@ "url": "https://packages.unity.com" }, "com.unity.timeline": { - "version": "1.2.18", + "version": "1.6.5", "depth": 0, "source": "registry", "dependencies": { @@ -264,6 +264,18 @@ "depth": 0, "source": "builtin", "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.uielementsnative": "1.0.0" + } + }, + "com.unity.modules.uielementsnative": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0" } diff --git a/ProjectSettings/MemorySettings.asset b/ProjectSettings/MemorySettings.asset new file mode 100644 index 0000000..5b5face --- /dev/null +++ b/ProjectSettings/MemorySettings.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!387306366 &1 +MemorySettings: + m_ObjectHideFlags: 0 + m_EditorMemorySettings: + m_MainAllocatorBlockSize: -1 + m_ThreadAllocatorBlockSize: -1 + m_MainGfxBlockSize: -1 + m_ThreadGfxBlockSize: -1 + m_CacheBlockSize: -1 + m_TypetreeBlockSize: -1 + m_ProfilerBlockSize: -1 + m_ProfilerEditorBlockSize: -1 + m_BucketAllocatorGranularity: -1 + m_BucketAllocatorBucketsCount: -1 + m_BucketAllocatorBlockSize: -1 + m_BucketAllocatorBlockCount: -1 + m_ProfilerBucketAllocatorGranularity: -1 + m_ProfilerBucketAllocatorBucketsCount: -1 + m_ProfilerBucketAllocatorBlockSize: -1 + m_ProfilerBucketAllocatorBlockCount: -1 + m_TempAllocatorSizeMain: -1 + m_JobTempAllocatorBlockSize: -1 + m_BackgroundJobTempAllocatorBlockSize: -1 + m_JobTempAllocatorReducedBlockSize: -1 + m_TempAllocatorSizeGIBakingWorker: -1 + m_TempAllocatorSizeNavMeshWorker: -1 + m_TempAllocatorSizeAudioWorker: -1 + m_TempAllocatorSizeCloudWorker: -1 + m_TempAllocatorSizeGfx: -1 + m_TempAllocatorSizeJobWorker: -1 + m_TempAllocatorSizeBackgroundWorker: -1 + m_TempAllocatorSizePreloadManager: -1 + m_PlatformMemorySettings: {} diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index ecaedcd..7b416d5 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.4.29f1 -m_EditorVersionWithRevision: 2019.4.29f1 (0eeae20b1d82) +m_EditorVersion: 2021.3.25f1 +m_EditorVersionWithRevision: 2021.3.25f1 (68ef2c4f8861) diff --git a/ProjectSettings/VersionControlSettings.asset b/ProjectSettings/VersionControlSettings.asset new file mode 100644 index 0000000..dca2881 --- /dev/null +++ b/ProjectSettings/VersionControlSettings.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!890905787 &1 +VersionControlSettings: + m_ObjectHideFlags: 0 + m_Mode: Visible Meta Files + m_CollabEditorSettings: + inProgressEnabled: 1 diff --git a/ProjectSettings/boot.config b/ProjectSettings/boot.config new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 80daefb..a52122f 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ For more information, including copyright, please refer to the following website ## Setup #### Requirement -* Unity 2019.4 or higher +* Unity 2021.3 or higher * uGUI (UIElements not supported) #### Install diff --git a/README_JA.md b/README_JA.md index 52c5e64..5951a2f 100644 --- a/README_JA.md +++ b/README_JA.md @@ -93,7 +93,7 @@ UnityのuGUIで画面遷移、画面遷移アニメーション、遷移履歴 ## セットアップ #### 要件 -* Unity 2019.4 以上 +* Unity 2021.3 以上 * uGUI (UIElementsには非対応) #### インストール