From f7e5dcf5a4c7d732c5c7a8d4bb1143daf69b9639 Mon Sep 17 00:00:00 2001 From: Haruki Yano Date: Wed, 15 Jun 2022 00:52:29 +0900 Subject: [PATCH] Allow to set AssetLoader for each Container. --- .../Runtime/Core/Modal/ModalContainer.cs | 14 ++++++++++++-- .../Runtime/Core/Page/PageContainer.cs | 14 ++++++++++++-- .../Runtime/Core/Sheet/SheetContainer.cs | 14 ++++++++++++-- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Modal/ModalContainer.cs b/Assets/UnityScreenNavigator/Runtime/Core/Modal/ModalContainer.cs index 7bebec4..5dac0a9 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Modal/ModalContainer.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Modal/ModalContainer.cs @@ -39,7 +39,17 @@ private readonly Dictionary> _assetLoadHandles private ModalBackdrop _backdropPrefab; private CanvasGroup _canvasGroup; - private IAssetLoader AssetLoader => UnityScreenNavigatorSettings.Instance.AssetLoader; + private IAssetLoader _assetLoader; + + /// + /// By default, in is used. + /// If this property is set, it is used instead. + /// + public IAssetLoader AssetLoader + { + get => _assetLoader ?? UnityScreenNavigatorSettings.Instance.AssetLoader; + set => _assetLoader = value; + } /// /// True if in transition. @@ -455,4 +465,4 @@ public void ReleasePreloaded(string resourceKey) AssetLoader.Release(handle); } } -} \ No newline at end of file +} diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Page/PageContainer.cs b/Assets/UnityScreenNavigator/Runtime/Core/Page/PageContainer.cs index a75961f..c6b78f2 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Page/PageContainer.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Page/PageContainer.cs @@ -36,7 +36,17 @@ private readonly Dictionary> _assetLoadHandles private bool _isActivePageStacked; - private IAssetLoader AssetLoader => UnityScreenNavigatorSettings.Instance.AssetLoader; + private IAssetLoader _assetLoader; + + /// + /// By default, in is used. + /// If this property is set, it is used instead. + /// + public IAssetLoader AssetLoader + { + get => _assetLoader ?? UnityScreenNavigatorSettings.Instance.AssetLoader; + set => _assetLoader = value; + } /// /// True if in transition. @@ -465,4 +475,4 @@ public void ReleasePreloaded(string resourceKey) AssetLoader.Release(handle); } } -} \ No newline at end of file +} diff --git a/Assets/UnityScreenNavigator/Runtime/Core/Sheet/SheetContainer.cs b/Assets/UnityScreenNavigator/Runtime/Core/Sheet/SheetContainer.cs index 09824c0..9c86018 100644 --- a/Assets/UnityScreenNavigator/Runtime/Core/Sheet/SheetContainer.cs +++ b/Assets/UnityScreenNavigator/Runtime/Core/Sheet/SheetContainer.cs @@ -33,7 +33,17 @@ private readonly Dictionary> _assetLoadHandles private int? _activeSheetId; private CanvasGroup _canvasGroup; - private IAssetLoader AssetLoader => UnityScreenNavigatorSettings.Instance.AssetLoader; + private IAssetLoader _assetLoader; + + /// + /// By default, in is used. + /// If this property is set, it is used instead. + /// + public IAssetLoader AssetLoader + { + get => _assetLoader ?? UnityScreenNavigatorSettings.Instance.AssetLoader; + set => _assetLoader = value; + } public int? ActiveSheetId => _activeSheetId; @@ -394,4 +404,4 @@ private IEnumerator HideRoutine(bool playAnimation) } } } -} \ No newline at end of file +}