//----------------------------------------------------------------------------- // Purpose: Load any materials that reference this texture. Used so we can refresh a // material's preview image if a relevant .vtf changes. //----------------------------------------------------------------------------- void CTextureSystem::ReloadMaterialsUsingTexture( ITexture *pTestTexture ) { for ( int i=0; i < m_Textures.Count(); i++ ) { IEditorTexture *pEditorTex = m_Textures[i]; IMaterial *pMat = pEditorTex->GetMaterial( false ); if ( !pMat ) continue; IMaterialVar **pParams = pMat->GetShaderParams(); int nParams = pMat->ShaderParamCount(); for ( int iParam=0; iParam < nParams; iParam++ ) { if ( pParams[iParam]->GetType() != MATERIAL_VAR_TYPE_TEXTURE ) continue; ITexture *pTex = pParams[iParam]->GetTextureValue(); if ( !pTex ) continue; if ( pTex == pTestTexture ) { pEditorTex->Reload( true ); } } } }