Skip to content

Commit 5cd2216

Browse files
committed
Fix TextureSize Getters
Errors were causing non-zero return values when executing the Commandlet. There might be a Bug in 5.3, but this will work for now.
1 parent 4987cbb commit 5cd2216

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

Source/Linter/Private/LintRules/LintRule_Texture_Size_NotTooBig.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright 2019-2020 Gamemakin LLC. All Rights Reserved.
22
#include "LintRules/LintRule_Texture_Size_NotTooBig.h"
3+
4+
#include "Linter.h"
35
#include "LintRuleSet.h"
46

57
ULintRule_Texture_Size_NotTooBig::ULintRule_Texture_Size_NotTooBig(const FObjectInitializer& ObjectInitializer) :
@@ -18,8 +20,15 @@ bool ULintRule_Texture_Size_NotTooBig::PassesRule(UObject* ObjectToLint, const U
1820
bool ULintRule_Texture_Size_NotTooBig::PassesRule_Internal_Implementation(UObject* ObjectToLint, const ULintRuleSet* ParentRuleSet, TArray<FLintRuleViolation>& OutRuleViolations) const {
1921
const UTexture2D* Texture = CastChecked<UTexture2D>(ObjectToLint);
2022

21-
const int32 TexSizeX = Texture->GetSizeX();
22-
const int32 TexSizeY = Texture->GetSizeY();
23+
// ToDo: Make Texture->GetSizeX() work again (possibly Bug in 5.3?)
24+
const FTexturePlatformData* PlatformData = Texture->GetPlatformData();
25+
if (!PlatformData) {
26+
UE_LOG(LogLinter, Warning, TEXT("Could not get Platform Data for Texture!"))
27+
return true;
28+
}
29+
30+
int32 TexSizeX = PlatformData->SizeX;
31+
int32 TexSizeY = PlatformData->SizeY;
2332

2433
// Check to see if textures are too big
2534
if (TexSizeX > MaxTextureSizeX || TexSizeY > MaxTextureSizeY) {

Source/Linter/Private/LintRules/LintRule_Texture_Size_PowerOfTwo.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright 2019-2020 Gamemakin LLC. All Rights Reserved.
22
#include "LintRules/LintRule_Texture_Size_PowerOfTwo.h"
3+
4+
#include "Linter.h"
35
#include "LintRuleSet.h"
46

57
ULintRule_Texture_Size_PowerOfTwo::ULintRule_Texture_Size_PowerOfTwo(const FObjectInitializer& ObjectInitializer) :
@@ -25,8 +27,15 @@ bool ULintRule_Texture_Size_PowerOfTwo::PassesRule(UObject* ObjectToLint, const
2527
bool ULintRule_Texture_Size_PowerOfTwo::PassesRule_Internal_Implementation(UObject* ObjectToLint, const ULintRuleSet* ParentRuleSet, TArray<FLintRuleViolation>& OutRuleViolations) const {
2628
const UTexture2D* Texture = CastChecked<UTexture2D>(ObjectToLint);
2729

28-
int32 TexSizeX = Texture->GetSizeX();
29-
int32 TexSizeY = Texture->GetSizeY();
30+
// ToDo: Make Texture->GetSizeX() work again (possibly Bug in 5.3?)
31+
const FTexturePlatformData* PlatformData = Texture->GetPlatformData();
32+
if (!PlatformData) {
33+
UE_LOG(LogLinter, Warning, TEXT("Could not get Platform Data for Texture!"))
34+
return true;
35+
}
36+
37+
int32 TexSizeX = PlatformData->SizeX;
38+
int32 TexSizeY = PlatformData->SizeY;
3039

3140
const bool bXFail = ((TexSizeX & (TexSizeX - 1)) != 0);
3241
const bool bYFail = ((TexSizeY & (TexSizeY - 1)) != 0);

0 commit comments

Comments
 (0)