Hey there.
So I’m trying to create a small Plugin that enables you to Replicate BLOBs of arbitrary size (for example textures). For that, I store my Data in a Struct that implements a custom NetSerialize
function that will try to split up the stored data into manageable chunks.
Unfortunately, this function is only called once, as objects only try to replicate when some Property changed. But since the Data in the Struct does not change, this is not happening.
Here is a rough overview:
UCLASS(Blueprintable)
class ULargeReplicatedActorComponent : public UActorComponent {
GENERATED_BODY()
public:
UPROPERTY(Replicated)
FLargeReplicatedObject Data;
ULargeReplicatedActorComponent() {
SetIsReplicatedByDefault(true);
SetNetAddressable();
}
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override {
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ULargeReplicatedActorComponent, Data);
}
};
USTRUCT()
struct FLargeReplicatedObject {
GENERATED_BODY()
// Stuff ....
UPROPERTY()
TArray<uint8> Data;
bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess);
// More Stuff ...
};
template<>
struct TStructOpsTypeTraits<FLargeReplicatedObject> : public TStructOpsTypeTraitsBase2<FLargeReplicatedObject> {
enum {
WithNetSerializer = true,
};
};
I tried to give the FLargeReplicatedObject
a COND_Custom
and always calling DOREPLIFETIME_ACTIVE_OVERRIDE
in PreReplication
, but Unreal still ignored the Property.
Using the Push Model or ForceNetUpdate()
also did not work.
If anyone has an idea, how I can force Unreal to replicate a Property, even though it has not changed, please let me know.
Thanks in Advance!