Fix prefab diff in Editor on mesh reference
This commit is contained in:
22
Source/Engine/Level/MeshReference.cs
Normal file
22
Source/Engine/Level/MeshReference.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user