浏览代码

Fix decal 'ghosts'

/main
Paul Melamed 6 年前
当前提交
83d9fc5d
共有 1 个文件被更改,包括 16 次插入10 次删除
  1. 26
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalProjectorComponent.cs

26
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalProjectorComponent.cs


public event OnMaterialChangeDelegate OnMaterialChange;
public void OnValidate()
{
// handle material changes
if (m_OldMaterial != m_Material)
{
if (m_Handle != null) // don't do anything if OnEnable hasn't been called yet when scene is loading.
if (m_Handle != null)
DecalSystem.instance.RemoveDecal(m_Handle);
m_Handle = DecalSystem.instance.AddDecal(transform, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material);
m_OldMaterial = m_Material;
// handle material changes, because decals are stored as sets sorted by material, if material changes decal needs to be removed and re-added to that it goes into correct set
if (m_OldMaterial != m_Material)
{
DecalSystem.instance.RemoveDecal(m_Handle);
m_Handle = DecalSystem.instance.AddDecal(transform, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Material);
m_OldMaterial = m_Material;
// notify the editor that material has changed so it can update the shader foldout
if (OnMaterialChange != null)
// notify the editor that material has changed so it can update the shader foldout
if (OnMaterialChange != null)
{
OnMaterialChange();
}
}
else // no material change, just update whatever else changed
OnMaterialChange();
DecalSystem.instance.UpdateCachedData(transform, sizeOffset, m_DrawDistance, m_FadeScale, uvScaleBias, m_AffectsTransparency, m_Handle);
}
}

正在加载...
取消
保存