Skip to content

Commit

Permalink
Fix crash when GetPixels called on zero size texture
Browse files Browse the repository at this point in the history
  • Loading branch information
drojf committed Aug 20, 2022
1 parent c421b9a commit 243721a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions MOD.Scripts.Core.Scene/MODSceneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ public static bool TryGetLayerFilter(int layer, out Filter value)

public static void ApplyFilters(int layer, Texture2D texture)
{
// This avoids a crash when "GetPixels32 called on a degenerate image (dimensions 0x0)"
// "UnityException: Texture '' is not configured correctly to allow GetPixels"
if (texture.width == 0 || texture.height == 0)
{
Debug.LogError("WARNING: ApplyFilters() called on texture with zero width and zero height. No filters will be applied.");
return;
}

if (!TryGetLayerFilter(layer, out Filter value)) { return; }
var watch = System.Diagnostics.Stopwatch.StartNew();
var pixels = texture.GetPixels32();
Expand Down

0 comments on commit 243721a

Please sign in to comment.