diff --git a/Packages/src/Runtime/Internal/Utilities/Misc.cs b/Packages/src/Runtime/Internal/Utilities/Misc.cs index 7b3f0ba..2412588 100644 --- a/Packages/src/Runtime/Internal/Utilities/Misc.cs +++ b/Packages/src/Runtime/Internal/Utilities/Misc.cs @@ -20,7 +20,9 @@ namespace Coffee.UIEffectInternal { public static T[] FindObjectsOfType() where T : Object { -#if UNITY_2023_1_OR_NEWER +#if UNITY_6000_4_OR_NEWER + return Object.FindObjectsByType(FindObjectsInactive.Include); +#elif UNITY_2023_1_OR_NEWER return Object.FindObjectsByType(FindObjectsInactive.Include, FindObjectsSortMode.None); #else return Object.FindObjectsOfType(); diff --git a/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs b/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs index 227b4da..e00e0f8 100644 --- a/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs +++ b/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs @@ -130,7 +130,7 @@ namespace Coffee.UIEffectInternal newEntry.hash = hash; newEntry.reference = 1; _cache[hash] = newEntry; - _objectKey[newObject.GetInstanceID()] = hash; + _objectKey[newObject.GetHashCode()] = hash; Logging.Log(_name, $"Add(total#{count}): {newEntry}"); Release(ref obj); obj = newObject; @@ -146,7 +146,7 @@ namespace Coffee.UIEffectInternal // Find and release the entry. Profiler.BeginSample("(COF)[ObjectRepository] Release"); - var id = obj.GetInstanceID(); + var id = obj.GetHashCode(); if (_objectKey.TryGetValue(id, out var hash) && _cache.TryGetValue(hash, out var entry)) { @@ -175,7 +175,7 @@ namespace Coffee.UIEffectInternal Profiler.BeginSample("(COF)[ObjectRepository] Remove"); _cache.Remove(entry.hash); - _objectKey.Remove(entry.storedObject.GetInstanceID()); + _objectKey.Remove(entry.storedObject.GetHashCode()); _pool.Push(entry); entry.reference = 0; Logging.Log(_name, $"Remove(total#{_cache.Count}): {entry}"); diff --git a/Packages/src/Runtime/Internal/Utilities/ShaderVariantRegistry.cs b/Packages/src/Runtime/Internal/Utilities/ShaderVariantRegistry.cs index 7408934..518425d 100644 --- a/Packages/src/Runtime/Internal/Utilities/ShaderVariantRegistry.cs +++ b/Packages/src/Runtime/Internal/Utilities/ShaderVariantRegistry.cs @@ -71,7 +71,7 @@ namespace Coffee.UIEffectInternal if (!shader) return null; // Already cached. - var id = shader.GetInstanceID(); + var id = shader.GetHashCode(); if (_cachedOptionalShaders.TryGetValue(id, out var optionalShaderName)) { return Shader.Find(optionalShaderName); @@ -270,7 +270,7 @@ namespace Coffee.UIEffectInternal _sb.Length--; // Remove last space. } - var hash = new Hash128((uint)shader.GetInstanceID(), (uint)GetContentsHash(_sb), 0, 0); + var hash = new Hash128((uint)shader.GetHashCode(), (uint)GetContentsHash(_sb), 0, 0); if (_cachedVariants.TryGetValue(hash, out var result)) { Profiler.EndSample(); diff --git a/Packages/src/Runtime/UIEffectBase.cs b/Packages/src/Runtime/UIEffectBase.cs index 486f0e9..59a6a3e 100644 --- a/Packages/src/Runtime/UIEffectBase.cs +++ b/Packages/src/Runtime/UIEffectBase.cs @@ -37,7 +37,7 @@ namespace Coffee.UIEffects public Material effectMaterial => _material; public Graphic graphic => _graphic ? _graphic : _graphic = GetComponent(); - public virtual uint effectId => (uint)GetInstanceID(); + public virtual uint effectId => (uint)GetHashCode(); public virtual float actualSamplingScale => 1; public virtual bool canModifyShape => true; @@ -188,8 +188,8 @@ namespace Coffee.UIEffects Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial"); var samplingScaleId = (uint)(Mathf.InverseLerp(0.01f, 100, actualSamplingScale) * uint.MaxValue); - var rootId = (uint)(transitionRoot ? transitionRoot.GetInstanceID() : 0); - var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, samplingScaleId, rootId); + var rootId = (uint)(transitionRoot ? transitionRoot.GetHashCode() : 0); + var hash = new Hash128((uint)baseMaterial.GetHashCode(), effectId, samplingScaleId, rootId); if (!MaterialRepository.Valid(hash, _material)) { Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial > Get or create material"); diff --git a/Packages/src/Runtime/UIEffectReplica.cs b/Packages/src/Runtime/UIEffectReplica.cs index 9ae5dbb..379abfb 100644 --- a/Packages/src/Runtime/UIEffectReplica.cs +++ b/Packages/src/Runtime/UIEffectReplica.cs @@ -102,8 +102,8 @@ namespace Coffee.UIEffects public override uint effectId => target ? target.effectId : preset - ? (uint)preset.GetInstanceID() - : (uint)GetInstanceID(); + ? (uint)preset.GetHashCode() + : (uint)GetHashCode(); public override UIEffectContext context