header
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Components/ProgressBar.h"
#include "Components/CanvasPanelSlot.h"
#include "MyUserWidget.generated.h"
/**
*
*/
UCLASS(Blueprintable,BlueprintType)
class MY_API UMyUserWidget : public UUserWidget
{
GENERATED_BODY()
public:
// progress bar
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UProgressBar* ProgBar; // <= name in widget needs to be the same
UFUNCTION(BlueprintCallable)
void SetSize(FVector2D newSize);
};
cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyUserWidget.h"
void UMyUserWidget::SetSize(FVector2D newSize)
{
UCanvasPanelSlot* CanvasSlot = Cast<UCanvasPanelSlot>(ProgBar->Slot);
CanvasSlot->SetSize(newSize);;
}
Add “UMG” to your build file
Reaction in widget

