fix: fix Unity6.5 compile errors and warnings

close #400
This commit is contained in:
tako
2026-04-21 10:46:13 +09:00
committed by mob-sakai
parent 859fa20d29
commit a5ee687821
5 changed files with 20 additions and 9 deletions

View File

@@ -78,10 +78,19 @@ namespace Coffee.UIExtensions
var mat = mats[j]; var mat = mats[j];
if (mat == null || mat.shader == null) continue; 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++) 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 name = ShaderUtil.GetPropertyName(mat.shader, i);
var type = (AnimatableProperty.ShaderPropertyType)ShaderUtil.GetPropertyType(mat.shader, i); var type = (AnimatableProperty.ShaderPropertyType)ShaderUtil.GetPropertyType(mat.shader, i);
#endif
if (!s_Names.Add(name)) continue; if (!s_Names.Add(name)) continue;
AddMenu(gm, sp, new ShaderProperty(name, type), true); AddMenu(gm, sp, new ShaderProperty(name, type), true);

View File

@@ -20,7 +20,9 @@ namespace Coffee.UIParticleInternal
{ {
public static T[] FindObjectsOfType<T>() where T : Object public static T[] FindObjectsOfType<T>() where T : Object
{ {
#if UNITY_2023_1_OR_NEWER #if UNITY_6000_5_OR_NEWER
return Object.FindObjectsByType<T>(FindObjectsInactive.Include);
#elif UNITY_2023_1_OR_NEWER
return Object.FindObjectsByType<T>(FindObjectsInactive.Include, FindObjectsSortMode.None); return Object.FindObjectsByType<T>(FindObjectsInactive.Include, FindObjectsSortMode.None);
#else #else
return Object.FindObjectsOfType<T>(); return Object.FindObjectsOfType<T>();

View File

@@ -130,7 +130,7 @@ namespace Coffee.UIParticleInternal
newEntry.hash = hash; newEntry.hash = hash;
newEntry.reference = 1; newEntry.reference = 1;
_cache[hash] = newEntry; _cache[hash] = newEntry;
_objectKey[newObject.GetInstanceID()] = hash; _objectKey[newObject.GetHashCode()] = hash;
Logging.Log(_name, $"<color=#03c700>Add</color>(total#{count}): {newEntry}"); Logging.Log(_name, $"<color=#03c700>Add</color>(total#{count}): {newEntry}");
Release(ref obj); Release(ref obj);
obj = newObject; obj = newObject;
@@ -146,7 +146,7 @@ namespace Coffee.UIParticleInternal
// Find and release the entry. // Find and release the entry.
Profiler.BeginSample("(COF)[ObjectRepository] Release"); Profiler.BeginSample("(COF)[ObjectRepository] Release");
var id = obj.GetInstanceID(); var id = obj.GetHashCode();
if (_objectKey.TryGetValue(id, out var hash) if (_objectKey.TryGetValue(id, out var hash)
&& _cache.TryGetValue(hash, out var entry)) && _cache.TryGetValue(hash, out var entry))
{ {
@@ -175,7 +175,7 @@ namespace Coffee.UIParticleInternal
Profiler.BeginSample("(COF)[ObjectRepository] Remove"); Profiler.BeginSample("(COF)[ObjectRepository] Remove");
_cache.Remove(entry.hash); _cache.Remove(entry.hash);
_objectKey.Remove(entry.storedObject.GetInstanceID()); _objectKey.Remove(entry.storedObject.GetHashCode());
_pool.Push(entry); _pool.Push(entry);
entry.reference = 0; entry.reference = 0;
Logging.Log(_name, $"<color=#f29e03>Remove</color>(total#{_cache.Count}): {entry}"); Logging.Log(_name, $"<color=#f29e03>Remove</color>(total#{_cache.Count}): {entry}");

View File

@@ -206,9 +206,9 @@ namespace Coffee.UIExtensions
} }
var hash = new Hash128( var hash = new Hash128(
modifiedMaterial ? (uint)modifiedMaterial.GetInstanceID() : 0, modifiedMaterial ? (uint)modifiedMaterial.GetHashCode() : 0,
texture ? (uint)texture.GetInstanceID() : 0, texture ? (uint)texture.GetHashCode() : 0,
0 < _parent.m_AnimatableProperties.Length ? (uint)GetInstanceID() : 0, 0 < _parent.m_AnimatableProperties.Length ? (uint)GetHashCode() : 0,
#if UNITY_EDITOR #if UNITY_EDITOR
(uint)EditorJsonUtility.ToJson(modifiedMaterial).GetHashCode() (uint)EditorJsonUtility.ToJson(modifiedMaterial).GetHashCode()
#else #else

View File

@@ -92,7 +92,7 @@ namespace Coffee.UIParticleInternal
if (sortByMaterial) if (sortByMaterial)
{ {
return aMat.GetInstanceID() - bMat.GetInstanceID(); return aMat.GetHashCode() - bMat.GetHashCode();
} }
if (aMat.renderQueue != bMat.renderQueue) if (aMat.renderQueue != bMat.renderQueue)
@@ -131,7 +131,7 @@ namespace Coffee.UIParticleInternal
{ {
for (var i = 0; i < list.Count; i++) for (var i = 0; i < list.Count; i++)
{ {
if (list[i].GetInstanceID() == ps.GetInstanceID()) if (list[i].GetHashCode() == ps.GetHashCode())
{ {
return i; return i;
} }