@@ -492,6 +492,16 @@ namespace FlaxEngine.Json
|
||||
writer.WriteValue(JsonSerializer.GetStringID(&id));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteJsonDiff(JsonWriter writer, object value, object other, Newtonsoft.Json.JsonSerializer serializer)
|
||||
{
|
||||
if (value is IControlReference valueRef &&
|
||||
other is IControlReference otherRef &&
|
||||
JsonSerializer.SceneObjectEquals(valueRef.UIControl, otherRef.UIControl))
|
||||
return;
|
||||
base.WriteJsonDiff(writer, value, other, serializer);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
|
||||
{
|
||||
@@ -499,7 +509,7 @@ namespace FlaxEngine.Json
|
||||
if (reader.TokenType == JsonToken.String && result is IControlReference controlReference)
|
||||
{
|
||||
JsonSerializer.ParseID((string)reader.Value, out var id);
|
||||
controlReference.UIControl = Object.Find<UIControl>(ref id);
|
||||
controlReference.Load(Object.Find<UIControl>(ref id));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -228,6 +228,23 @@ namespace FlaxEngine.Json
|
||||
CacheManagedOnly.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default implementation of the values comparision function used by the serialization system.
|
||||
/// </summary>
|
||||
/// <param name="objA">The object a.</param>
|
||||
/// <param name="objB">The object b.</param>
|
||||
/// <returns>True if both objects are equal, otherwise false.</returns>
|
||||
public static bool SceneObjectEquals(SceneObject objA, SceneObject objB)
|
||||
{
|
||||
if (objA == objB)
|
||||
return true;
|
||||
if (objA == null || objB == null)
|
||||
return false;
|
||||
if (objA.HasPrefabLink && objB.HasPrefabLink)
|
||||
return objA.PrefabObjectID == objB.PrefabObjectID;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default implementation of the values comparision function used by the serialization system.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user