Fix scene object reference serialization in Visual Script properties
#3136
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include "Engine/Profiler/ProfilerCPU.h"
|
#include "Engine/Profiler/ProfilerCPU.h"
|
||||||
#include "Engine/Utilities/StringConverter.h"
|
#include "Engine/Utilities/StringConverter.h"
|
||||||
#include "Engine/Threading/MainThreadTask.h"
|
#include "Engine/Threading/MainThreadTask.h"
|
||||||
|
#include "Engine/Level/SceneObject.h"
|
||||||
#include "FlaxEngine.Gen.h"
|
#include "FlaxEngine.Gen.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -40,6 +41,22 @@ namespace
|
|||||||
Log::Logger::Write(type, stack);
|
Log::Logger::Write(type, stack);
|
||||||
Log::Logger::Write(type, TEXT(""));
|
Log::Logger::Write(type, TEXT(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SerializeValue(const Variant& a, const Variant& b)
|
||||||
|
{
|
||||||
|
bool result = a != b;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
// Special case for scene objects to handle prefab object references
|
||||||
|
auto* aSceneObject = ScriptingObject::Cast<SceneObject>((ScriptingObject*)a);
|
||||||
|
auto* bSceneObject = ScriptingObject::Cast<SceneObject>((ScriptingObject*)b);
|
||||||
|
if (aSceneObject && bSceneObject)
|
||||||
|
{
|
||||||
|
result = Serialization::ShouldSerialize(aSceneObject, bSceneObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VISUAL_SCRIPT_DEBUGGING
|
#if VISUAL_SCRIPT_DEBUGGING
|
||||||
@@ -1960,7 +1977,7 @@ void VisualScriptingBinaryModule::SerializeObject(JsonWriter& stream, ScriptingO
|
|||||||
auto& param = asset->Graph.Parameters[paramIndex];
|
auto& param = asset->Graph.Parameters[paramIndex];
|
||||||
auto& value = params[paramIndex];
|
auto& value = params[paramIndex];
|
||||||
auto& otherValue = otherParams->Value.Params[paramIndex];
|
auto& otherValue = otherParams->Value.Params[paramIndex];
|
||||||
if (value != otherValue)
|
if (SerializeValue(value, otherValue))
|
||||||
{
|
{
|
||||||
param.Identifier.ToString(idName, Guid::FormatType::N);
|
param.Identifier.ToString(idName, Guid::FormatType::N);
|
||||||
stream.Key(idName, 32);
|
stream.Key(idName, 32);
|
||||||
@@ -1975,7 +1992,7 @@ void VisualScriptingBinaryModule::SerializeObject(JsonWriter& stream, ScriptingO
|
|||||||
auto& param = asset->Graph.Parameters[paramIndex];
|
auto& param = asset->Graph.Parameters[paramIndex];
|
||||||
auto& value = params[paramIndex];
|
auto& value = params[paramIndex];
|
||||||
auto& otherValue = param.Value;
|
auto& otherValue = param.Value;
|
||||||
if (value != otherValue)
|
if (SerializeValue(value, otherValue))
|
||||||
{
|
{
|
||||||
param.Identifier.ToString(idName, Guid::FormatType::N);
|
param.Identifier.ToString(idName, Guid::FormatType::N);
|
||||||
stream.Key(idName, 32);
|
stream.Key(idName, 32);
|
||||||
|
|||||||
Reference in New Issue
Block a user