Skip to content

Commit 1e2b024

Browse files
committed
don't enable JSITextMesh if it's not invalidated
1 parent 57cf180 commit 1e2b024

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

RasterPropMonitor/Core/JSITextMesh.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,6 @@ private void CreateComponents()
257257
meshRenderer_.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
258258
meshRenderer_.receiveShadows = true; // not working?
259259
meshRenderer_.material = new Material(JUtil.LoadInternalShader("RPM/JSILabel"));
260-
261-
var enabler = gameObject.AddComponent<VisibilityEnabler>();
262-
enabler.Initialize(this);
263260
}
264261
}
265262

@@ -272,6 +269,19 @@ public void Start()
272269
CreateComponents();
273270
}
274271

272+
void OnBecameVisible()
273+
{
274+
if (!string.IsNullOrEmpty(text) && (invalidated || invalidatedColor))
275+
{
276+
enabled = true;
277+
}
278+
}
279+
280+
void OnBecameInvisible()
281+
{
282+
enabled = false;
283+
}
284+
275285
/// <summary>
276286
/// Make sure we don't leave our callback lingering.
277287
/// </summary>

0 commit comments

Comments
 (0)