Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 0e3c681

Browse files
committed
Fixed nullref due to a potential race condition
1 parent 2d1db29 commit 0e3c681

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

PostProcessing/Runtime/Components/DitheringComponent.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,25 @@ public override bool active
2323

2424
const int k_TextureCount = 64;
2525

26-
public override void OnEnable()
26+
public override void OnDisable()
27+
{
28+
noiseTextures = null;
29+
}
30+
31+
void LoadNoiseTextures()
2732
{
2833
noiseTextures = new Texture2D[k_TextureCount];
2934

3035
for (int i = 0; i < k_TextureCount; i++)
3136
noiseTextures[i] = Resources.Load<Texture2D>("Bluenoise64/LDR_LLL1_" + i);
3237
}
3338

34-
public override void OnDisable()
35-
{
36-
noiseTextures = null;
37-
}
38-
3939
public override void Prepare(Material uberMaterial)
4040
{
4141
float rndOffsetX;
4242
float rndOffsetY;
4343

4444
#if POSTFX_DEBUG_STATIC_DITHERING
45-
// Chosen by a fair dice roll
4645
textureIndex = 0;
4746
rndOffsetX = 0f;
4847
rndOffsetY = 0f;
@@ -54,6 +53,9 @@ public override void Prepare(Material uberMaterial)
5453
rndOffsetY = Random.value;
5554
#endif
5655

56+
if (noiseTextures == null)
57+
LoadNoiseTextures();
58+
5759
var noiseTex = noiseTextures[textureIndex];
5860

5961
uberMaterial.EnableKeyword("DITHERING");

0 commit comments

Comments
 (0)