ExoWest/Source/Exo/Private/Widget/UWBP_RoundProgressBar.cpp

36 lines
834 B
C++

// Fill out your copyright notice in the Description page of Project Settings.
#include "Widget/UWBP_RoundProgressBar.h"
#include "Components/Image.h"
#include "Styling/SlateBrush.h"
void UUWBP_RoundProgressBar::BeginDestroy()
{
Super::BeginDestroy();
}
void UUWBP_RoundProgressBar::SetPercent(float percent)
{
if (!DynamicMaterial)
{
if (!ImageBar)
return;
FSlateBrush brush= ImageBar->GetBrush();
UMaterialInterface* material=Cast<UMaterialInterface>(brush.GetResourceObject());
if (!material)
return;
DynamicMaterial = UMaterialInstanceDynamic::Create(material, this);
if (DynamicMaterial)
{
FSlateBrush newBrush= brush;
newBrush.SetResourceObject(DynamicMaterial);
ImageBar->SetBrush(newBrush);
}
}
if (DynamicMaterial)
DynamicMaterial->SetScalarParameterValue("Percent",percent);
}