diff --git a/Packages/src/Editor/AnimatablePropertyEditor.cs b/Packages/src/Editor/AnimatablePropertyEditor.cs index 38bdec9..f3e5de1 100644 --- a/Packages/src/Editor/AnimatablePropertyEditor.cs +++ b/Packages/src/Editor/AnimatablePropertyEditor.cs @@ -78,10 +78,19 @@ public static void Draw(SerializedProperty sp, List mats) 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/Packages/src/Editor/UIParticleMenu.cs b/Packages/src/Editor/UIParticleMenu.cs index 256a4f9..8fab617 100644 --- a/Packages/src/Editor/UIParticleMenu.cs +++ b/Packages/src/Editor/UIParticleMenu.cs @@ -6,11 +6,19 @@ namespace Coffee.UIExtensions { internal class UIParticleMenu { +#if UNITY_6000_5_OR_NEWER + [MenuItem("GameObject/UI (Canvas)/Particle System (Empty)", false, 2018)] +#else [MenuItem("GameObject/UI/Particle System (Empty)", false, 2018)] +#endif private static void AddParticleEmpty(MenuCommand menuCommand) { // Create empty UI element. +#if UNITY_6000_5_OR_NEWER + EditorApplication.ExecuteMenuItem("GameObject/UI (Canvas)/Image"); +#else EditorApplication.ExecuteMenuItem("GameObject/UI/Image"); +#endif var ui = Selection.activeGameObject; Object.DestroyImmediate(ui.GetComponent()); @@ -21,7 +29,11 @@ private static void AddParticleEmpty(MenuCommand menuCommand) uiParticle.rectTransform.sizeDelta = Vector2.zero; } +#if UNITY_6000_5_OR_NEWER + [MenuItem("GameObject/UI (Canvas)/Particle System", false, 2019)] +#else [MenuItem("GameObject/UI/Particle System", false, 2019)] +#endif private static void AddParticle(MenuCommand menuCommand) { // Create empty UIEffect. @@ -29,7 +41,11 @@ private static void AddParticle(MenuCommand menuCommand) var uiParticle = Selection.activeGameObject.GetComponent(); // Create ParticleSystem. +#if UNITY_6000_5_OR_NEWER + EditorApplication.ExecuteMenuItem("GameObject/Visual Effects/Particle System"); +#else EditorApplication.ExecuteMenuItem("GameObject/Effects/Particle System"); +#endif var ps = Selection.activeGameObject; ps.transform.SetParent(uiParticle.transform, false); ps.transform.localPosition = Vector3.zero; diff --git a/Packages/src/Runtime/Internal/Utilities/Misc.cs b/Packages/src/Runtime/Internal/Utilities/Misc.cs index 58769e9..353abe6 100644 --- a/Packages/src/Runtime/Internal/Utilities/Misc.cs +++ b/Packages/src/Runtime/Internal/Utilities/Misc.cs @@ -20,7 +20,9 @@ internal static class Misc { 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/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs b/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs index 9797789..67a2c24 100644 --- a/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs +++ b/Packages/src/Runtime/Internal/Utilities/ObjectRepository.cs @@ -130,7 +130,11 @@ private void Add(Hash128 hash, ref T obj, T newObject) newEntry.hash = hash; newEntry.reference = 1; _cache[hash] = newEntry; +#if UNITY_6000_5_OR_NEWER + _objectKey[newObject.GetEntityId().GetHashCode()] = hash; +#else _objectKey[newObject.GetInstanceID()] = hash; +#endif Logging.Log(_name, $"Add(total#{count}): {newEntry}"); Release(ref obj); obj = newObject; @@ -146,7 +150,11 @@ public void Release(ref T obj) // Find and release the entry. Profiler.BeginSample("(COF)[ObjectRepository] Release"); +#if UNITY_6000_5_OR_NEWER + var id = obj.GetEntityId().GetHashCode(); +#else var id = obj.GetInstanceID(); +#endif if (_objectKey.TryGetValue(id, out var hash) && _cache.TryGetValue(hash, out var entry)) { @@ -175,7 +183,11 @@ private void Remove(Entry entry) Profiler.BeginSample("(COF)[ObjectRepository] Remove"); _cache.Remove(entry.hash); +#if UNITY_6000_5_OR_NEWER + _objectKey.Remove(entry.storedObject.GetEntityId().GetHashCode()); +#else _objectKey.Remove(entry.storedObject.GetInstanceID()); +#endif _pool.Push(entry); entry.reference = 0; Logging.Log(_name, $"Remove(total#{_cache.Count}): {entry}"); diff --git a/Packages/src/Runtime/UIParticleRenderer.cs b/Packages/src/Runtime/UIParticleRenderer.cs index 814c137..4c951fa 100644 --- a/Packages/src/Runtime/UIParticleRenderer.cs +++ b/Packages/src/Runtime/UIParticleRenderer.cs @@ -204,10 +204,17 @@ public override Material GetModifiedMaterial(Material baseMaterial) return modifiedMaterial; } +#if UNITY_6000_5_OR_NEWER + var hash = new Hash128( + modifiedMaterial ? (uint)modifiedMaterial.GetEntityId().GetHashCode() : 0, + texture ? (uint)texture.GetEntityId().GetHashCode() : 0, + 0 < _parent.m_AnimatableProperties.Length ? (uint)GetEntityId().GetHashCode() : 0, +#else var hash = new Hash128( modifiedMaterial ? (uint)modifiedMaterial.GetInstanceID() : 0, texture ? (uint)texture.GetInstanceID() : 0, 0 < _parent.m_AnimatableProperties.Length ? (uint)GetInstanceID() : 0, +#endif #if UNITY_EDITOR (uint)EditorJsonUtility.ToJson(modifiedMaterial).GetHashCode() #else diff --git a/Packages/src/Runtime/Utilities/ParticleSystemExtensions.cs b/Packages/src/Runtime/Utilities/ParticleSystemExtensions.cs index ee59b7d..e791681 100644 --- a/Packages/src/Runtime/Utilities/ParticleSystemExtensions.cs +++ b/Packages/src/Runtime/Utilities/ParticleSystemExtensions.cs @@ -92,7 +92,11 @@ public static void SortForRendering(this List self, Transform tr if (sortByMaterial) { +#if UNITY_6000_5_OR_NEWER + return aMat.GetEntityId().GetHashCode() - bMat.GetEntityId().GetHashCode(); +#else return aMat.GetInstanceID() - bMat.GetInstanceID(); +#endif } if (aMat.renderQueue != bMat.renderQueue) @@ -131,7 +135,11 @@ private static int GetIndex(IList list, Object ps) { for (var i = 0; i < list.Count; i++) { +#if UNITY_6000_5_OR_NEWER + if (list[i].GetEntityId().GetHashCode() == ps.GetEntityId().GetHashCode()) +#else if (list[i].GetInstanceID() == ps.GetInstanceID()) +#endif { return i; }