Auto-call OnRep on server after editor property change + ForceNetUpdate
- After ImportText, automatically call the property's RepNotifyFunc via reflection - ForceNetUpdate ensures replication to clients (OnRep fires on both server and client) - No BP changes needed — fully transparent for replicated properties Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2121,10 +2121,28 @@ void UPS_Editor_MainWidget::ApplyPropertyFromUI(int32 RowIndex)
|
|||||||
UE_LOG(LogTemp, Warning, TEXT("PS_Editor: ApplyProperty '%s' = '%s' -> Import %s"),
|
UE_LOG(LogTemp, Warning, TEXT("PS_Editor: ApplyProperty '%s' = '%s' -> Import %s"),
|
||||||
*Row.Key, *NewValueText, ImportResult ? TEXT("OK") : TEXT("FAILED"));
|
*Row.Key, *NewValueText, ImportResult ? TEXT("OK") : TEXT("FAILED"));
|
||||||
|
|
||||||
// Refresh rendering
|
// Refresh rendering + force network replication (triggers OnRep on clients)
|
||||||
if (UActorComponent* Comp = Cast<UActorComponent>(Target))
|
if (UActorComponent* Comp = Cast<UActorComponent>(Target))
|
||||||
{
|
{
|
||||||
Comp->MarkRenderStateDirty();
|
Comp->MarkRenderStateDirty();
|
||||||
|
if (AActor* OwnerActor = Comp->GetOwner())
|
||||||
|
{
|
||||||
|
OwnerActor->ForceNetUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Actor->ForceNetUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Auto-call OnRep on the server (ImportText bypasses replication notify)
|
||||||
|
if (!Row.CachedProperty->RepNotifyFunc.IsNone())
|
||||||
|
{
|
||||||
|
if (UFunction* RepFunc = Target->FindFunction(Row.CachedProperty->RepNotifyFunc))
|
||||||
|
{
|
||||||
|
Target->ProcessEvent(RepFunc, nullptr);
|
||||||
|
UE_LOG(LogTemp, Log, TEXT("PS_Editor: Called %s on %s"), *Row.CachedProperty->RepNotifyFunc.ToString(), *Target->GetName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export new value after import (normalized form for undo)
|
// Export new value after import (normalized form for undo)
|
||||||
|
|||||||
Reference in New Issue
Block a user