Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Assets/UnityScreenNavigator/Runtime/Core/Modal/ModalContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
using UnityScreenNavigator.Runtime.Foundation;
using UnityScreenNavigator.Runtime.Foundation.AssetLoader;
using UnityScreenNavigator.Runtime.Foundation.Coroutine;
#if UNITY_6000_4_OR_NEWER
using TransformId = UnityEngine.EntityId;
#else
using TransformId = System.Int32;
#endif

namespace UnityScreenNavigator.Runtime.Core.Modal
{
[RequireComponent(typeof(RectMask2D))]
public sealed class ModalContainer : MonoBehaviour, IScreenContainer
{
private static readonly Dictionary<int, ModalContainer> InstanceCacheByTransform = new();
private static readonly Dictionary<TransformId, ModalContainer> InstanceCacheByTransform = new();

private static readonly Dictionary<string, ModalContainer> InstanceCacheByName = new();

Expand Down Expand Up @@ -101,7 +106,7 @@ private void OnDestroy()
_orderedModalIds.Clear();

InstanceCacheByName.Remove(_name);
var keysToRemove = new List<int>();
var keysToRemove = new List<TransformId>();
foreach (var cache in InstanceCacheByTransform)
if (Equals(cache.Value))
keysToRemove.Add(cache.Key);
Expand Down Expand Up @@ -141,7 +146,11 @@ public static ModalContainer Of(Transform transform, bool useCache = true)
/// <returns></returns>
public static ModalContainer Of(RectTransform rectTransform, bool useCache = true)
{
#if UNITY_6000_4_OR_NEWER
var id = rectTransform.GetEntityId();
#else
var id = rectTransform.GetInstanceID();
#endif
if (useCache && InstanceCacheByTransform.TryGetValue(id, out var container)) return container;

container = rectTransform.GetComponentInParent<ModalContainer>();
Expand Down
13 changes: 11 additions & 2 deletions Assets/UnityScreenNavigator/Runtime/Core/Page/PageContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
using UnityScreenNavigator.Runtime.Foundation;
using UnityScreenNavigator.Runtime.Foundation.AssetLoader;
using UnityScreenNavigator.Runtime.Foundation.Coroutine;
#if UNITY_6000_4_OR_NEWER
using TransformId = UnityEngine.EntityId;
#else
using TransformId = System.Int32;
#endif

namespace UnityScreenNavigator.Runtime.Core.Page
{
[RequireComponent(typeof(RectMask2D))]
public sealed class PageContainer : MonoBehaviour, IScreenContainer
{
private static readonly Dictionary<int, PageContainer> InstanceCacheByTransform = new();
private static readonly Dictionary<TransformId, PageContainer> InstanceCacheByTransform = new();

private static readonly Dictionary<string, PageContainer> InstanceCacheByName = new();

Expand Down Expand Up @@ -90,7 +95,7 @@ private void OnDestroy()
_orderedPageIds.Clear();

InstanceCacheByName.Remove(_name);
var keysToRemove = new List<int>();
var keysToRemove = new List<TransformId>();
foreach (var cache in InstanceCacheByTransform)
if (Equals(cache.Value))
keysToRemove.Add(cache.Key);
Expand Down Expand Up @@ -130,7 +135,11 @@ public static PageContainer Of(Transform transform, bool useCache = true)
/// <returns></returns>
public static PageContainer Of(RectTransform rectTransform, bool useCache = true)
{
#if UNITY_6000_4_OR_NEWER
var id = rectTransform.GetEntityId();
#else
var id = rectTransform.GetInstanceID();
#endif
if (useCache && InstanceCacheByTransform.TryGetValue(id, out var container)) return container;

container = rectTransform.GetComponentInParent<PageContainer>();
Expand Down
15 changes: 12 additions & 3 deletions Assets/UnityScreenNavigator/Runtime/Core/Sheet/SheetContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
using UnityScreenNavigator.Runtime.Foundation;
using UnityScreenNavigator.Runtime.Foundation.AssetLoader;
using UnityScreenNavigator.Runtime.Foundation.Coroutine;
#if UNITY_6000_4_OR_NEWER
using TransformId = UnityEngine.EntityId;
#else
using TransformId = System.Int32;
#endif

namespace UnityScreenNavigator.Runtime.Core.Sheet
{
[RequireComponent(typeof(RectMask2D))]
public sealed class SheetContainer : MonoBehaviour, IScreenContainer
{
private static readonly Dictionary<int, SheetContainer> InstanceCacheByTransform =
new Dictionary<int, SheetContainer>();
private static readonly Dictionary<TransformId, SheetContainer> InstanceCacheByTransform =
new Dictionary<TransformId, SheetContainer>();

private static readonly Dictionary<string, SheetContainer> InstanceCacheByName =
new Dictionary<string, SheetContainer>();
Expand Down Expand Up @@ -94,7 +99,7 @@ private void OnDestroy()
UnregisterAll();

InstanceCacheByName.Remove(_name);
var keysToRemove = new List<int>();
var keysToRemove = new List<TransformId>();
foreach (var cache in InstanceCacheByTransform)
if (Equals(cache.Value))
keysToRemove.Add(cache.Key);
Expand Down Expand Up @@ -123,7 +128,11 @@ public static SheetContainer Of(Transform transform, bool useCache = true)
/// <returns></returns>
public static SheetContainer Of(RectTransform rectTransform, bool useCache = true)
{
#if UNITY_6000_4_OR_NEWER
var hashCode = rectTransform.GetEntityId();
#else
var hashCode = rectTransform.GetInstanceID();
#endif

if (useCache && InstanceCacheByTransform.TryGetValue(hashCode, out var container)) return container;

Expand Down
4 changes: 2 additions & 2 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "66de0d3a58b256b6e0194f285cc530fd0c08407b"
"hash": "ceac8d6946b1125fe782cd171fbcb245b567dbf9"
},
"com.harumak.unityuiplayables": {
"version": "https://github.com/Haruma-K/UnityUIPlayables.git?path=/Assets/UnityUIPlayables",
Expand Down Expand Up @@ -115,9 +115,9 @@
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0"
},
"url": "https://packages.unity.com"
Expand Down