Subobject Replication for Blueprint Child Class

I can setup any UObject I want to replicate in C++ and it does it well with all properties and even sub-sub objects can replicate. However if I create a new Blueprint Object from that same UObject that replicates so well in code and give it new properties that also need to replicate, than those new properties do not replicate at all. I can add a RepNotify to them and the rep notify only gets called on the server. The Subobject exists on both the server and the client, and all the properties that are setup to replicate in C++ replicate just fine, but none of the added blueprint properties do.

My current setup for this is to override the IsSupportedForNetworking() function
Second Step AActors, UActorComponents override the ReplicateSubobjects function
This replicates the subobjects one at a time or using a for loop if they are in an array.

/**
* Setup Property replication
*/
void USubObjectComponent::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
        Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME(USubObjectComponent, subObjects);
}

/**
* Allows Subobject replication on a UObject, must be explicitly called from owning object.
* param Channel
* param Bunch
* param RepFlags  */
  bool USubObjectComponent::ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags)
{
    bool wroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags); for (UMySubObject * subObject: this->subObjects)
    {
        if (subObject!= nullptr && !subObject->IsPendingKill())
        {
            wroteSomething |= Channel->ReplicateSubobject(subObject, *Bunch, *RepFlags);  
            // sub-sub object replication, it works!
            wroteSomething |= subObject->ReplicateSubobjects(Channel, Bunch, RepFlags);
        }
     }
    return wroteSomething;
}

Holy cow you just saved my framework! Thanks for reposting that!

So to elaborate on the solution, if you have a Replicated UObject you have created and need Blueprint Variables to also replicate add this to the root class of your replicated UObject’s GetLifetimeReplicatedPropers:

 UBlueprintGeneratedClass * bpClass = Cast<UBlueprintGeneratedClass>(this->GetClass());
 if (bpClass != nullptr)
 {
     bpClass->GetLifetimeBlueprintReplicationList(OutLifetimeProps);
 }

Great Find! Thanks for posting the source.