Skip to content

Commit 2b44837

Browse files
committed
fix: TextMeshPro is not displayed in prefab mode
close #295
1 parent 1d849e5 commit 2b44837

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Packages/src/Runtime/UIEffectBase.cs

-10
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,6 @@ public virtual void SetVerticesDirty()
164164
if (isActiveAndEnabled)
165165
{
166166
OnTMPChanged(textMeshProUGUI);
167-
var canvas = graphic.canvas;
168-
if (canvas && graphic.isActiveAndEnabled)
169-
{
170-
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord2;
171-
}
172167
}
173168
else if (0 < textMeshProUGUI.textInfo?.meshInfo?.Length
174169
&& 0 < textMeshProUGUI.textInfo.meshInfo[0].vertexCount)
@@ -181,11 +176,6 @@ public virtual void SetVerticesDirty()
181176
if (graphic)
182177
{
183178
graphic.SetVerticesDirty();
184-
var canvas = graphic.canvas;
185-
if (canvas && graphic.isActiveAndEnabled)
186-
{
187-
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord1;
188-
}
189179
}
190180
}
191181

Packages/src/Runtime/Utilities/ContextProcessor.cs

+12
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public virtual void OnPreModifyMesh(Graphic graphic)
6565
UIVertexUtil.onLerpVertex = s_OnLerpVertex;
6666
ShadowUtil.onMarkAsShadow = s_OnMarkAsShadow;
6767
UIEffectContext.onModifyVertex = s_OnModifyVertex;
68+
69+
var canvas = graphic.canvas;
70+
if (canvas)
71+
{
72+
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord1;
73+
}
6874
}
6975

7076
private static readonly Func<UIVertex, UIVertex, UIVertex, float, UIVertex> s_OnLerpVertex =
@@ -121,6 +127,12 @@ public override void OnPreModifyMesh(Graphic graphic)
121127
UIVertexUtil.onLerpVertex = s_OnLerpVertex;
122128
ShadowUtil.onMarkAsShadow = s_OnMarkAsShadow;
123129
UIEffectContext.onModifyVertex = s_OnModifyVertex;
130+
131+
var canvas = graphic.canvas;
132+
if (canvas)
133+
{
134+
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord2;
135+
}
124136
}
125137

126138
private static readonly Func<UIVertex, UIVertex, UIVertex, float, UIVertex> s_OnLerpVertex =

0 commit comments

Comments
 (0)