Unity 6 compatibility

This commit is contained in:
Pascal Serrarens 2026-05-26 09:23:07 +02:00
parent 133804a154
commit 1a7ca0e298
2 changed files with 18 additions and 3 deletions

View File

@ -26,15 +26,26 @@ namespace NanoBrain.Unity {
public static readonly Dictionary<string, ClusterView> clusterViews = new();
public static ClusterView GetClusterView(SerializedProperty property) {
string key = property.propertyPath + "_" + property.serializedObject.targetObject.GetInstanceID();//GetEntityId();
#if UNITY_6000_0_OR_NEWER
EntityId id = property.serializedObject.targetObject.GetEntityId();
#else
int id = property.serializedObject.targetObject.GetInstanceID();
#endif
string key = property.propertyPath + "_" + id;
if (!clusterViews.TryGetValue(key, out ClusterView clusterView))
clusterView = new(key);// { key = key };
return clusterView;
}
public static ClusterView GetClusterView(SerializedObject serializedObject) {
string key = serializedObject.targetObject.GetInstanceID().ToString(); //GetEntityId().ToString();
#if UNITY_6000_0_OR_NEWER
EntityId id = serializedObject.targetObject.GetEntityId();
#else
int id = property.serializedObject.targetObject.GetInstanceID();
#endif
string key = id.ToString();
if (!clusterViews.TryGetValue(key, out ClusterView clusterView))
clusterView = new(key); // { key = key };
clusterView = new(key);
return clusterView;
}

View File

@ -15,7 +15,11 @@ namespace NanoBrain.Braitenberg {
protected override float SampleSensor() {
float sum = 0f;
// Get all active lights in scene (Point lights only)
#if UNITY_6000_0_OR_NEWER
Light[] lights = FindObjectsByType<Light>();
#else
Light[] lights = FindObjectsByType<Light>(FindObjectsSortMode.None);
#endif
Vector3 pos = transform.position;
Vector3 forward = transform.forward;