在两个位于不同 Clip Box 的 GoWrapper 内使用同一个 Material, Material 的 ClipBox Property 的值会错误

在 GoWrapper.cs 及 UpdateContext.cs 内, Clipping 相关 property 是直接 set 在 shared material 的
这样会导致使用同一个 material 但在两个不同的 Clip Box 时其中一个 Clip Box Value 错误
  virtual protected void ApplyClipping(UpdateContext context)
{
#if UNITY_2018_2_OR_NEWER
int cnt = _renderers.Count;
for (int i = 0; i < cnt; i++)
{
Renderer renderer = _renderers[i].renderer;
if (renderer == null)
continue;

if (customCloneMaterials != null)
helperMaterials.AddRange(_materialsBackup.Values);
else
renderer.GetSharedMaterials(helperMaterials);

int cnt2 = helperMaterials.Count;
for (int j = 0; j < cnt2; j++)
{
Material mat = helperMaterials[j];
if (mat != null)
context.ApplyClippingProperties(mat, false);
}

helperMaterials.Clear();
}
#else
...

 我这边先把
renderer.GetSharedMaterials(helperMaterials);
改为
renderer.GetMaterials( helperMaterials );
用 Material Instance 暂时解决了问题
 
想问正确做法是不要在 GoWrapper 使用 Shared Material 吗? 还是可以改为使用 Material Property Block 支援这种情况?
已邀请:

谷主

赞同来自:

这种情况,你应该自行clone材质

要回复问题请先登录注册