Fix prefab diff in Editor on mesh reference

This commit is contained in:
Wojtek Figat
2025-06-02 11:50:10 +02:00
parent 4d9407e4e9
commit 6c499e877f
2 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
// Copyright (c) Wojciech Figat. All rights reserved.
using FlaxEngine.Json;
namespace FlaxEngine
{
partial class ModelInstanceActor
{
partial struct MeshReference : ICustomValueEquals
{
/// <inheritdoc />
public bool ValueEquals(object other)
{
var o = (MeshReference)other;
return JsonSerializer.ValueEquals(Actor, o.Actor) &&
LODIndex == o.LODIndex &&
MeshIndex == o.MeshIndex;
}
}
}
}

View File

@@ -27,6 +27,11 @@ namespace FlaxEngine.Json
} }
} }
internal interface ICustomValueEquals
{
bool ValueEquals(object other);
}
partial class JsonSerializer partial class JsonSerializer
{ {
internal class SerializerCache internal class SerializerCache
@@ -262,7 +267,7 @@ namespace FlaxEngine.Json
return true; return true;
if (objA == null || objB == null) if (objA == null || objB == null)
return false; return false;
// Special case when saving reference to prefab object and the objects are different but the point to the same prefab object // Special case when saving reference to prefab object and the objects are different but the point to the same prefab object
// In that case, skip saving reference as it's defined in prefab (will be populated via IdsMapping during deserialization) // In that case, skip saving reference as it's defined in prefab (will be populated via IdsMapping during deserialization)
if (objA is SceneObject sceneA && objB is SceneObject sceneB && sceneA && sceneB && sceneA.HasPrefabLink && sceneB.HasPrefabLink) if (objA is SceneObject sceneA && objB is SceneObject sceneB && sceneA && sceneB && sceneA.HasPrefabLink && sceneB.HasPrefabLink)
@@ -311,6 +316,8 @@ namespace FlaxEngine.Json
return !bEnumerator.MoveNext(); return !bEnumerator.MoveNext();
} }
if (objA is ICustomValueEquals customValueEquals && objA.GetType() == objB.GetType())
return customValueEquals.ValueEquals(objB);
return objA.Equals(objB); return objA.Equals(objB);
#endif #endif
} }