diff --git a/Editor/AnimatablePropertyEditor.cs b/Editor/AnimatablePropertyEditor.cs index 38bdec9..f3e5de1 100644 --- a/Editor/AnimatablePropertyEditor.cs +++ b/Editor/AnimatablePropertyEditor.cs @@ -78,10 +78,19 @@ namespace Coffee.UIExtensions var mat = mats[j]; if (mat == null || mat.shader == null) continue; +#if UNITY_6000_5_OR_NEWER + for (var i = 0; i < mat.shader.GetPropertyCount(); i++) +#else for (var i = 0; i < ShaderUtil.GetPropertyCount(mat.shader); i++) +#endif { +#if UNITY_6000_5_OR_NEWER + var name = mat.shader.GetPropertyName(i); + var type = (AnimatableProperty.ShaderPropertyType)mat.shader.GetPropertyType(i); +#else var name = ShaderUtil.GetPropertyName(mat.shader, i); var type = (AnimatableProperty.ShaderPropertyType)ShaderUtil.GetPropertyType(mat.shader, i); +#endif if (!s_Names.Add(name)) continue; AddMenu(gm, sp, new ShaderProperty(name, type), true); diff --git a/Runtime/Internal/Utilities/Misc.cs b/Runtime/Internal/Utilities/Misc.cs index 58769e9..353abe6 100644 --- a/Runtime/Internal/Utilities/Misc.cs +++ b/Runtime/Internal/Utilities/Misc.cs @@ -20,7 +20,9 @@ namespace Coffee.UIParticleInternal { public static T[] FindObjectsOfType() where T : Object { -#if UNITY_2023_1_OR_NEWER +#if UNITY_6000_5_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/Runtime/Internal/Utilities/ObjectRepository.cs b/Runtime/Internal/Utilities/ObjectRepository.cs index 9797789..9f47e16 100644 --- a/Runtime/Internal/Utilities/ObjectRepository.cs +++ b/Runtime/Internal/Utilities/ObjectRepository.cs @@ -130,7 +130,7 @@ namespace Coffee.UIParticleInternal 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.UIParticleInternal // 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.UIParticleInternal 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/Runtime/UIParticleRenderer.cs b/Runtime/UIParticleRenderer.cs index e152777..f6c0162 100644 --- a/Runtime/UIParticleRenderer.cs +++ b/Runtime/UIParticleRenderer.cs @@ -206,9 +206,9 @@ namespace Coffee.UIExtensions } var hash = new Hash128( - modifiedMaterial ? (uint)modifiedMaterial.GetInstanceID() : 0, - texture ? (uint)texture.GetInstanceID() : 0, - 0 < _parent.m_AnimatableProperties.Length ? (uint)GetInstanceID() : 0, + modifiedMaterial ? (uint)modifiedMaterial.GetHashCode() : 0, + texture ? (uint)texture.GetHashCode() : 0, + 0 < _parent.m_AnimatableProperties.Length ? (uint)GetHashCode() : 0, #if UNITY_EDITOR (uint)EditorJsonUtility.ToJson(modifiedMaterial).GetHashCode() #else diff --git a/Runtime/Utilities/ParticleSystemExtensions.cs b/Runtime/Utilities/ParticleSystemExtensions.cs index ee59b7d..292078f 100644 --- a/Runtime/Utilities/ParticleSystemExtensions.cs +++ b/Runtime/Utilities/ParticleSystemExtensions.cs @@ -92,7 +92,7 @@ namespace Coffee.UIParticleInternal if (sortByMaterial) { - return aMat.GetInstanceID() - bMat.GetInstanceID(); + return aMat.GetHashCode() - bMat.GetHashCode(); } if (aMat.renderQueue != bMat.renderQueue) @@ -131,7 +131,7 @@ namespace Coffee.UIParticleInternal { for (var i = 0; i < list.Count; i++) { - if (list[i].GetInstanceID() == ps.GetInstanceID()) + if (list[i].GetHashCode() == ps.GetHashCode()) { return i; }