UEditorUtilitySubsystem* EditorUtilitySubsystem = GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>(); if (EditorUtilitySubsystem) { FAssetData SuraToolsAsset( TEXT("/SuraControlPanel/SURA-ToolSets511"), // SURA-ToolSets511.uasset TEXT("/SuraControlPanel"), TEXT("SURA-ToolSets511"), UEditorUtilityWidgetBlueprint::StaticClass()->GetClassPathName() ); // asset路径在编辑器里通过Reference Viewer可以获得 auto WidgetBP = CastChecked<UEditorUtilityWidgetBlueprint>(SuraToolsAsset.GetAsset()); if (TabID == NAME_None) { EditorUtilitySubsystem->SpawnAndRegisterTabAndGetID(WidgetBP, TabID); } else { if (EditorUtilitySubsystem->DoesTabExist(TabID)) { EditorUtilitySubsystem->CloseTabByID(TabID); } else { EditorUtilitySubsystem->SpawnRegisteredTabByID(TabID); } } } |