本文整理汇总了C++中UObject::CollectDefaultSubobjects方法的典型用法代码示例。如果您正苦于以下问题:C++ UObject::CollectDefaultSubobjects方法的具体用法?C++ UObject::CollectDefaultSubobjects怎么用?C++ UObject::CollectDefaultSubobjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UObject
的用法示例。
在下文中一共展示了UObject::CollectDefaultSubobjects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateDefaultProperties
void FHotReloadClassReinstancer::UpdateDefaultProperties()
{
struct FPropertyToUpdate
{
UProperty* Property;
FName SubobjectName;
uint8* OldSerializedValuePtr;
uint8* NewValuePtr;
int64 OldSerializedSize;
};
/** Memory writer archive that supports UObject values the same way as FCDOWriter. */
class FPropertyValueMemoryWriter : public FMemoryWriter
{
public:
FPropertyValueMemoryWriter(TArray<uint8>& OutData)
: FMemoryWriter(OutData)
{}
virtual FArchive& operator<<(class UObject*& InObj) override
{
FArchive& Ar = *this;
if (InObj)
{
FName ClassName = InObj->GetClass()->GetFName();
FName ObjectName = InObj->GetFName();
Ar << ClassName;
Ar << ObjectName;
}
else
{
FName UnusedName = NAME_None;
Ar << UnusedName;
Ar << UnusedName;
}
return *this;
}
virtual FArchive& operator<<(FName& InName) override
{
FArchive& Ar = *this;
NAME_INDEX ComparisonIndex = InName.GetComparisonIndex();
NAME_INDEX DisplayIndex = InName.GetDisplayIndex();
int32 Number = InName.GetNumber();
Ar << ComparisonIndex;
Ar << DisplayIndex;
Ar << Number;
return Ar;
}
virtual FArchive& operator<<(FLazyObjectPtr& LazyObjectPtr) override
{
FArchive& Ar = *this;
auto UniqueID = LazyObjectPtr.GetUniqueID();
Ar << UniqueID;
return *this;
}
virtual FArchive& operator<<(FAssetPtr& AssetPtr) override
{
FArchive& Ar = *this;
auto UniqueID = AssetPtr.GetUniqueID();
Ar << UniqueID;
return Ar;
}
virtual FArchive& operator<<(FStringAssetReference& Value) override
{
FArchive& Ar = *this;
Ar << Value.AssetLongPathname;
return Ar;
}
};
// Collect default subobjects to update their properties too
const int32 DefaultSubobjectArrayCapacity = 16;
TArray<UObject*> DefaultSubobjectArray;
DefaultSubobjectArray.Empty(DefaultSubobjectArrayCapacity);
NewClass->GetDefaultObject()->CollectDefaultSubobjects(DefaultSubobjectArray);
TArray<FPropertyToUpdate> PropertiesToUpdate;
// Collect all properties that have actually changed
for (auto& Pair : ReconstructedCDOProperties.Properties)
{
auto OldPropertyInfo = OriginalCDOProperties.Properties.Find(Pair.Key);
if (OldPropertyInfo)
{
auto& NewPropertyInfo = Pair.Value;
uint8* OldSerializedValuePtr = OriginalCDOProperties.Bytes.GetData() + OldPropertyInfo->SerializedValueOffset;
uint8* NewSerializedValuePtr = ReconstructedCDOProperties.Bytes.GetData() + NewPropertyInfo.SerializedValueOffset;
if (OldPropertyInfo->SerializedValueSize != NewPropertyInfo.SerializedValueSize ||
FMemory::Memcmp(OldSerializedValuePtr, NewSerializedValuePtr, OldPropertyInfo->SerializedValueSize) != 0)
{
// Property value has changed so add it to the list of properties that need updating on instances
FPropertyToUpdate PropertyToUpdate;
PropertyToUpdate.Property = NewPropertyInfo.Property;
PropertyToUpdate.NewValuePtr = nullptr;
PropertyToUpdate.SubobjectName = NewPropertyInfo.SubobjectName;
if (NewPropertyInfo.Property->GetOuter() == NewClass)
{
PropertyToUpdate.NewValuePtr = PropertyToUpdate.Property->ContainerPtrToValuePtr<uint8>(NewClass->GetDefaultObject());
}
else if (NewPropertyInfo.SubobjectName != NAME_None)
{
//.........这里部分代码省略.........