Unity 2022 compatibility

This commit is contained in:
Pascal Serrarens 2026-08-10 11:30:45 +02:00
parent fb51cc8914
commit 808bb949cf
2 changed files with 9 additions and 1 deletions

View File

@ -54,14 +54,22 @@ namespace NanoBrain.Unity {
return EditorGUIUtility.singleLineHeight + propertyExtraHeight; return EditorGUIUtility.singleLineHeight + propertyExtraHeight;
} }
#if UNITY_6000_0_OR_NEWER
private readonly Dictionary<EntityId, bool> _invalidCache = new(); private readonly Dictionary<EntityId, bool> _invalidCache = new();
#else
private readonly Dictionary<int, bool> _invalidCache = new();
#endif
private bool IsInvalidJson(SerializedProperty jsonFileProp) { private bool IsInvalidJson(SerializedProperty jsonFileProp) {
TextAsset jsonFile = jsonFileProp.objectReferenceValue as TextAsset; TextAsset jsonFile = jsonFileProp.objectReferenceValue as TextAsset;
if (jsonFile == null) if (jsonFile == null)
return false; return false;
#if UNITY_6000_0_OR_NEWER
EntityId id = jsonFile.GetEntityId(); EntityId id = jsonFile.GetEntityId();
#else
int id = jsonFile.GetInstanceID();
#endif
if (_invalidCache.TryGetValue(id, out bool invalid)) if (_invalidCache.TryGetValue(id, out bool invalid))
return invalid; return invalid;

View File

@ -41,7 +41,7 @@ namespace NanoBrain.Unity {
#if UNITY_6000_0_OR_NEWER #if UNITY_6000_0_OR_NEWER
EntityId id = serializedObject.targetObject.GetEntityId(); EntityId id = serializedObject.targetObject.GetEntityId();
#else #else
int id = property.serializedObject.targetObject.GetInstanceID(); int id = serializedObject.targetObject.GetInstanceID();
#endif #endif
string key = id.ToString(); string key = id.ToString();
if (!clusterViews.TryGetValue(key, out ClusterView clusterView)) if (!clusterViews.TryGetValue(key, out ClusterView clusterView))