@@ -52,15 +52,27 @@ public virtual UIEffectContext context
52
52
53
53
protected override void OnEnable ( )
54
54
{
55
- UIExtraCallbacks . onScreenSizeChangedAction += SetVerticesDirtyIfTextMeshPro ;
55
+ #if TMP_ENABLE
56
+ if ( graphic is TextMeshProUGUI )
57
+ {
58
+ _prevLossyScaleY = transform . lossyScale . y ;
59
+ UIExtraCallbacks . onAfterCanvasRebuild += CheckSDFScaleForTMP ;
60
+ UIExtraCallbacks . onScreenSizeChangedAction += SetVerticesDirtyForTMP ;
61
+ }
62
+ #endif
63
+
56
64
UpdateContext ( context ) ;
57
65
SetMaterialDirty ( ) ;
58
66
SetVerticesDirty ( ) ;
59
67
}
60
68
61
69
protected override void OnDisable ( )
62
70
{
63
- UIExtraCallbacks . onScreenSizeChangedAction -= SetVerticesDirtyIfTextMeshPro ;
71
+ #if TMP_ENABLE
72
+ UIExtraCallbacks . onScreenSizeChangedAction -= SetVerticesDirtyForTMP ;
73
+ UIExtraCallbacks . onAfterCanvasRebuild -= CheckSDFScaleForTMP ;
74
+ #endif
75
+
64
76
MaterialRepository . Release ( ref _material ) ;
65
77
SetMaterialDirty ( ) ;
66
78
SetVerticesDirty ( ) ;
@@ -200,18 +212,6 @@ public virtual void SetVerticesDirty()
200
212
}
201
213
}
202
214
203
-
204
- private void SetVerticesDirtyIfTextMeshPro ( )
205
- {
206
- #if TMP_ENABLE
207
- if ( graphic && graphic . isActiveAndEnabled
208
- && ( graphic is TextMeshProUGUI || graphic is TMP_SubMeshUI ) )
209
- {
210
- graphic . SetVerticesDirty ( ) ;
211
- }
212
- #endif
213
- }
214
-
215
215
public virtual void SetMaterialDirty ( )
216
216
{
217
217
if ( graphic )
@@ -348,6 +348,28 @@ private static TMP_SubMeshUI GetSubMeshUI(List<TMP_SubMeshUI> subMeshes, Materia
348
348
349
349
return null ;
350
350
}
351
+
352
+ private void SetVerticesDirtyForTMP ( )
353
+ {
354
+ if ( graphic && graphic . isActiveAndEnabled )
355
+ {
356
+ graphic . SetVerticesDirty ( ) ;
357
+ }
358
+ }
359
+
360
+ private void CheckSDFScaleForTMP ( )
361
+ {
362
+ var lossyScaleY = transform . lossyScale . y ;
363
+ if ( Mathf . Approximately ( _prevLossyScaleY , lossyScaleY ) ) return ;
364
+
365
+ _prevLossyScaleY = lossyScaleY ;
366
+ if ( graphic is TextMeshProUGUI textMeshProUGUI && graphic . isActiveAndEnabled )
367
+ {
368
+ OnTMPChanged ( textMeshProUGUI ) ;
369
+ }
370
+ }
371
+
372
+ private float _prevLossyScaleY ;
351
373
#endif
352
374
353
375
public abstract void SetRate ( float rate , UIEffectTweener . CullingMask cullingMask ) ;
0 commit comments