| 295 | } |
| 296 | |
| 297 | void FURLabEditorModule::OnObjectModified(UObject* Object) |
| 298 | { |
| 299 | if (bIsAutoParenting) |
| 300 | return; |
| 301 | |
| 302 | USimpleConstructionScript* SCS = Cast<USimpleConstructionScript>(Object); |
| 303 | if (!SCS) |
| 304 | return; |
| 305 | |
| 306 | UBlueprint* BP = SCS->GetBlueprint(); |
| 307 | if (!BP || !BP->GeneratedClass || !BP->GeneratedClass->IsChildOf(AMjArticulation::StaticClass())) |
| 308 | return; |
| 309 | |
| 310 | // Defer to next tick so the SCS tree is fully updated before we scan |
| 311 | TWeakObjectPtr<USimpleConstructionScript> WeakSCS = SCS; |
| 312 | TWeakObjectPtr<UBlueprint> WeakBP = BP; |
| 313 | GEditor->GetTimerManager()->SetTimerForNextTick([this, WeakSCS, WeakBP]() { |
| 314 | if (bIsAutoParenting) |
| 315 | return; |
| 316 | USimpleConstructionScript* SCSPtr = WeakSCS.Get(); |
| 317 | UBlueprint* BPPtr = WeakBP.Get(); |
| 318 | if (!SCSPtr || !BPPtr) |
| 319 | return; |
| 320 | |
| 321 | TArray<USCS_Node*> AllNodes = SCSPtr->GetAllNodes(); |
| 322 | bIsAutoParenting = true; |
| 323 | bool bMoved = false; |
| 324 | |
| 325 | for (USCS_Node* Node : AllNodes) |
| 326 | { |
| 327 | bMoved |= AutoParentSCSNode(Node, SCSPtr); |
| 328 | } |
| 329 | bIsAutoParenting = false; |
| 330 | |
| 331 | if (bMoved) |
| 332 | { |
| 333 | FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(BPPtr); |
| 334 | } |
| 335 | }); |
| 336 | } |
| 337 | |
| 338 | bool FURLabEditorModule::AutoParentSCSNode(USCS_Node* Node, USimpleConstructionScript* SCS) |
| 339 | { |
nothing calls this directly
no outgoing calls
no test coverage detected