Add recursive function to modify widgets positions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "UETools.hpp"
|
||||
#include "Engine_classes.hpp"
|
||||
#include "UMG_classes.hpp"
|
||||
|
||||
SDK::APawn* GetPawnFromWorld(SDK::UWorld* world) {
|
||||
if (!world) world = SDK::UWorld::GetWorld();
|
||||
@@ -60,4 +61,24 @@ void ReactivateDevConsole(std::shared_ptr<spdlog::logger> logger) {
|
||||
return;
|
||||
}
|
||||
}).detach();
|
||||
}
|
||||
|
||||
void ApplyOffsetsRecursive(SDK::UWidget* widget, float left, float right) {
|
||||
if (widget && widget->Slot && widget->Slot->IsA(SDK::UCanvasPanelSlot::StaticClass())) {
|
||||
auto* slot = (SDK::UCanvasPanelSlot*)widget->Slot;
|
||||
if (!slot) return;
|
||||
SDK::FMargin offsets = slot->GetOffsets();
|
||||
|
||||
if (offsets.Left != left || offsets.Right != right) {
|
||||
offsets.Left = left;
|
||||
offsets.Right = right;
|
||||
slot->SetOffsets(offsets);
|
||||
}
|
||||
}
|
||||
// Go down if UPanelWidget
|
||||
if (widget && widget->IsA(SDK::UPanelWidget::StaticClass())) {
|
||||
if (auto* panel = (SDK::UPanelWidget*)widget)
|
||||
for (int i = 0; i < panel->GetChildrenCount(); ++i)
|
||||
ApplyOffsetsRecursive(panel->GetChildAt(i), left, right);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user