Closed TheComicRelief closed 2 weeks ago
same for me also spray preview doesn't work 20% of the time I've found (some rooms completely don't allow the preview)
I'm guessing this is the error being discussed:
[Error : Unity Log] NullReferenceException
Stack trace:
SprayPaintItemExt.Update () (at D:/SteamLibrary/steamapps/common/Lethal Company/projects/BetterSprayPaint/src/SprayPaintItemExt.cs:151
This happens because Unity overloads the ==
operator to handle checking if the object was destroyed.
Source: https://stackoverflow.com/a/72072517/1581233
This can be fixed by removing the null-propagating operator:
--- a/src/SprayPaintItemExt.cs
+++ b/src/SprayPaintItemExt.cs
@@ -148,7 +148,7 @@ public class SprayPaintItemExt: MonoBehaviour {
var c = net.CurrentColor;
var factor = (Mathf.Sin(Time.timeSinceLevelLoad * 6f) + 1f) * 0.2f + 0.2f;
previewFadeFactor = Utils.Lexp(previewFadeFactor, active ? 1f : 0f, 15f * Time.deltaTime);
- if (previewDecal?.gameObject != null && previewDecal.material != null) {
+ if (previewDecal != null && previewDecal.gameObject != null && previewDecal.material != null) {
previewDecal.material.color = new Color(
Mathf.Lerp(c.r, Math.Min(c.r + 0.35f, 1f), factor),
Mathf.Lerp(c.g, Math.Min(c.g + 0.35f, 1f), factor),
Mod spams error in console.