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 ) ;
}
}