Skip to content

Commit 0a37aa7

Browse files
authored
Merge pull request #1 from OpenSourceUnityPackage/fix/texture_leak
fix: texture leak
2 parents ceadf4c + 1629811 commit 0a37aa7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Runtime/TerrainFogOfWar.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ public Color[] GetDatas(int x, int y, int width, int height)
148148
texture.Apply();
149149

150150
RenderTexture.active = null; // added to avoid errors
151-
return texture.GetPixels();
151+
Color[] rst = texture.GetPixels();
152+
Texture2D.Destroy(texture);
153+
154+
return rst;
152155
}
153156

154157
private void GenerateRenderTexture()
@@ -255,4 +258,4 @@ static bool IsDiscInsideAABB(Vector2 discCenter, float discRadius, Vector2 rectM
255258
return (ex < discRadius) && (ey < discRadius) && (ex * ex + ey * ey < discRadius * discRadius);
256259
}
257260
}
258-
}
261+
}

0 commit comments

Comments
 (0)