Skip to content

Commit 243721a

Browse files
committed
Fix crash when GetPixels called on zero size texture
1 parent c421b9a commit 243721a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

MOD.Scripts.Core.Scene/MODSceneController.cs

+8
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ public static bool TryGetLayerFilter(int layer, out Filter value)
193193

194194
public static void ApplyFilters(int layer, Texture2D texture)
195195
{
196+
// This avoids a crash when "GetPixels32 called on a degenerate image (dimensions 0x0)"
197+
// "UnityException: Texture '' is not configured correctly to allow GetPixels"
198+
if (texture.width == 0 || texture.height == 0)
199+
{
200+
Debug.LogError("WARNING: ApplyFilters() called on texture with zero width and zero height. No filters will be applied.");
201+
return;
202+
}
203+
196204
if (!TryGetLayerFilter(layer, out Filter value)) { return; }
197205
var watch = System.Diagnostics.Stopwatch.StartNew();
198206
var pixels = texture.GetPixels32();

0 commit comments

Comments
 (0)