Skip to content

Commit 5f0e186

Browse files
authored
Merge pull request #24 from JanSeliv/develop
Develop
2 parents f88bf71 + c48810d commit 5f0e186

4 files changed

Lines changed: 24 additions & 13 deletions

File tree

CustomShapeButton.uplugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"DocsURL": "",
1111
"MarketplaceURL": "",
1212
"SupportURL": "mailto:janseliw@gmail.com",
13-
"EngineVersion": "5.5.0",
13+
"EngineVersion": "5.6.0",
1414
"EnabledByDefault": true,
1515
"CanContainContent": false,
1616
"IsBetaVersion": false,

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<a href="https://github.com/JanSeliv/CustomShapeButton/blob/main/LICENSE">![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)</a>
2-
<a href="https://www.unrealengine.com/">![Unreal Engine](https://img.shields.io/badge/Unreal-5.5-dea309?style=flat&logo=unrealengine)</a>
2+
<a href="https://www.unrealengine.com/">![Unreal Engine](https://img.shields.io/badge/Unreal-5.6-dea309?style=flat&logo=unrealengine)</a>
33

44
<br/>
55
<p align="center">
@@ -35,6 +35,8 @@ Detailed documentation about the Custom Shape Button can be found [here](https:/
3535
Check out our [Release](https://github.com/JanSeliv/CustomShapeButton/releases) page for a sample project showcasing the Custom Shape Button plugin.
3636

3737
## 📅 Changelog
38+
#### 2025-11-17
39+
- Updated to **Unreal Engine 5.6**
3840
#### 2025-06-27
3941
- Updated to **Unreal Engine 5.5**
4042
- [Bug] Fixed overlapping don't work on covered areas when stacked on top of each other: added `Overlap Order` setting for proper handing underlying buttons

Source/CustomShapeButton/CustomShapeButton.Build.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public CustomShapeButton(ReadOnlyTargetRules Target) : base(Target)
88
{
99
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
1010
CppStandard = CppStandardVersion.Latest;
11-
bEnableNonInlinedGenCppWarnings = true;
11+
CppCompileWarningSettings.NonInlinedGenCppWarningLevel = WarningLevel.Error;
1212

1313
PublicDependencyModuleNames.AddRange(new[]
1414
{

Source/CustomShapeButton/Private/SCustomShapeButton.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,25 +215,34 @@ void SCustomShapeButton::UpdateRawColors_Texture(const UTexture2D& Texture)
215215

216216
// Get Raw Colors data on Render thread
217217
TWeakPtr<SCustomShapeButton> WeakThisPtr = StaticCastWeakPtr<SCustomShapeButton>(AsWeak());
218-
checkf(WeakThisPtr.IsValid(), TEXT("ERROR: [%i] %hs:\n'WeakThis' is not valid!"), __LINE__, __FUNCTION__);
219-
const TWeakObjectPtr<const UTexture2D> WeakTexture = &Texture;
218+
const TWeakObjectPtr WeakTexture(&Texture);
220219
const FIntRect TextureSize(0, 0, TextureRes.X, TextureRes.Y);
221220
ENQUEUE_RENDER_COMMAND(TryUpdateRawColorsOnce)([WeakThisPtr, WeakTexture, TextureSize](FRHICommandListImmediate& RHICmdList)
222221
{
223-
SCustomShapeButton* This = WeakThisPtr.Pin().Get();
224-
if (!ensureMsgf(This, TEXT("ASSERT: [%i] %hs:\n'This' is not valid!"), __LINE__, __FUNCTION__))
222+
const UTexture2D* Texture2D = WeakTexture.Get();
223+
const FTextureResource* TextureResource = Texture2D ? Texture2D->GetResource() : nullptr;
224+
FRHITexture* RHITexture = TextureResource ? TextureResource->GetTexture2DRHI() : nullptr;
225+
if (!ensureMsgf(RHITexture, TEXT("%hs: 'RHITexture' is not valid"), __FUNCTION__))
225226
{
226227
return;
227228
}
228229

229-
const UTexture2D* Texture2D = WeakTexture.Get();
230-
const FTextureResource* TextureResource = Texture2D ? Texture2D->GetResource() : nullptr;
231-
FRHITexture* RHITexture = TextureResource ? TextureResource->GetTexture2DRHI() : nullptr;
232-
if (ensureMsgf(RHITexture, TEXT("%hs: 'RHITexture' is not valid"), __FUNCTION__))
230+
// Obtain data
231+
TArray<FColor> OutColors;
232+
RHICmdList.ReadSurfaceData(RHITexture, TextureSize, OutColors, FReadSurfaceDataFlags());
233+
if (!ensureMsgf(!OutColors.IsEmpty(), TEXT("ASSERT: [%i] %hs:\n'OutColors' is empty, failed to read texture data!"), __LINE__, __FUNCTION__))
233234
{
234-
// Copy data to cache
235-
RHICmdList.ReadSurfaceData(RHITexture, TextureSize, /*out*/This->RawColors, FReadSurfaceDataFlags());
235+
return;
236236
}
237+
238+
// Set the data on Game thread
239+
AsyncTask(ENamedThreads::GameThread, [WeakThisPtr, TempColors = MoveTemp(OutColors)]() mutable -> void
240+
{
241+
if (SCustomShapeButton* This = WeakThisPtr.Pin().Get())
242+
{
243+
This->RawColors = MoveTemp(TempColors);
244+
}
245+
});
237246
});
238247
}
239248

0 commit comments

Comments
 (0)