Compatible with Unreal Engine 5.7#32
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the editor support utilities to be compatible with Unreal Engine 5.7 by replacing deprecated global object/class lookup patterns and adding required includes.
Changes:
- Replaced
FindObject<UClass>(ANY_PACKAGE, ...)usages withFindFirstObjectSafe<UClass>(...)across MCP utility code. - Added missing include for
FStringOutputDeviceusage in widget utilities.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Source/GenerativeAISupportEditor/Private/MCP/GenWidgetUtils.cpp | Adds StringOutputDevice include and updates widget class lookup to FindFirstObjectSafe. |
| Source/GenerativeAISupportEditor/Private/MCP/GenBlueprintUtils.cpp | Updates class/component lookup to FindFirstObjectSafe (note: one prefixed lookup likely regresses behavior). |
| Source/GenerativeAISupportEditor/Private/MCP/GenBlueprintNodeCreator.cpp | Updates node/library class lookups to FindFirstObjectSafe (note: node class name prefixing looks incorrect). |
| Source/GenerativeAISupportEditor/Private/MCP/GenActorUtils.cpp | Updates actor/game mode class lookup to FindFirstObjectSafe (note: unused FullClassName and missing fallback). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| FString PrefixedClassName = TEXT("/Script/Engine.") + ClassName; | ||
| Class = FindObject<UClass>(ANY_PACKAGE, *PrefixedClassName); | ||
| Class = FindFirstObjectSafe<UClass>(*PrefixedClassName); |
There was a problem hiding this comment.
FindFirstObjectSafe is being called with a "/Script/Engine.<Class>"-style string. FindFirstObjectSafe searches by object name and may not resolve object paths, so this prefixed lookup can become a no-op and regress class resolution. Consider using LoadClass/StaticLoadClass for "/Script/..." paths (or FindObject with a nullptr outer + full path) and keep FindFirstObjectSafe for unqualified names only.
| Class = FindFirstObjectSafe<UClass>(*PrefixedClassName); | |
| Class = StaticLoadClass(UObject::StaticClass(), nullptr, *PrefixedClassName); |
| // Try to find class by name | ||
| FString FullClassName = FString::Printf(TEXT("/Script/Engine.%s"), *ActorClassName); | ||
| ActorClass = FindObject<UClass>(ANY_PACKAGE, *ActorClassName); | ||
| ActorClass = FindFirstObjectSafe<UClass>(*ActorClassName); | ||
|
|
||
| if (!ActorClass) |
There was a problem hiding this comment.
FullClassName is constructed but never used, and the class lookup only tries the unqualified ActorClassName. Either remove FullClassName or use it as a fallback (e.g., attempt to load/find "/Script/Engine.<ActorClassName>") so engine classes resolve consistently.
| } | ||
|
|
||
| UClass* NodeClass = FindObject<UClass>(ANY_PACKAGE, *(TEXT("UK2Node_") + ActualNodeType)); | ||
| UClass* NodeClass = FindFirstObjectSafe<UClass>(*(TEXT("UK2Node_") + ActualNodeType)); |
There was a problem hiding this comment.
The lookup uses "UK2Node_" + ActualNodeType, but UObject names for these classes typically drop the U prefix (e.g., UK2Node_IfThenElse has the object name K2Node_IfThenElse). This means the first lookup will never match and wastes work; it can also prevent finding nodes when only the class name suffix is provided. Consider using "K2Node_" + ActualNodeType (and/or avoid double-prefixing when ActualNodeType already starts with K2Node_).
| UClass* NodeClass = FindFirstObjectSafe<UClass>(*(TEXT("UK2Node_") + ActualNodeType)); | |
| FString LookupName = ActualNodeType; | |
| if (!ActualNodeType.StartsWith(TEXT("K2Node_"))) | |
| { | |
| LookupName = TEXT("K2Node_") + ActualNodeType; | |
| } | |
| UClass* NodeClass = FindFirstObjectSafe<UClass>(*LookupName); |
Adds compatibility with Unreal Engine 5.7