@@ -54,6 +54,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
5454
5555 if ( m_FirstTimeApply )
5656 {
57+ this . currentMaterialInfo . hasMesh = false ;
5758 OnOpenGUI ( targetMat , materialEditor , properties ) ;
5859
5960 if ( MaterialModificationTracker . CanEdit ( materialEditor . target as Material ) )
@@ -159,6 +160,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
159160
160161 private struct MaterialInfo
161162 {
163+ public bool hasMesh ;
162164 public bool hasColor ;
163165 public bool hasUV0 ;
164166 public bool hasUV1 ;
@@ -260,6 +262,7 @@ private void DrawGameObjectInfo(Material targetMaterial)
260262 haveDrawnSomething = true ;
261263 }
262264
265+ currentMaterialInfo . hasMesh = false ;
263266 currentMaterialInfo . hasColor = true ;
264267 currentMaterialInfo . hasUV0 = true ;
265268 currentMaterialInfo . hasUV1 = true ;
@@ -276,6 +279,7 @@ private void DrawGameObjectInfo(Material targetMaterial)
276279
277280 if ( mesh )
278281 {
282+ currentMaterialInfo . hasMesh = true ;
279283 currentMaterialInfo . hasColor = mesh . HasVertexAttribute ( VertexAttribute . Color ) ;
280284 currentMaterialInfo . hasUV0 = mesh . HasVertexAttribute ( VertexAttribute . TexCoord0 ) ;
281285 currentMaterialInfo . hasUV1 = mesh . HasVertexAttribute ( VertexAttribute . TexCoord1 ) ;
@@ -531,20 +535,32 @@ private void DrawProperties(Material targetMaterial, MaterialProperty[] properti
531535 propertyList . RemoveAll ( x => x . name == "occlusionStrength" || ( x . name . StartsWith ( "occlusionTexture" , StringComparison . Ordinal ) && x . name != "occlusionTexture" ) ) ;
532536 }
533537 // remove UV-related properties
534- if ( HasPropertyButNoTex ( targetMaterial , "baseColorTexture" ) && HasPropertyButNoTex ( targetMaterial , "metallicRoughnessTexture" ) && HasPropertyButNoTex ( targetMaterial , "normalTexture" ) && HasPropertyButNoTex ( targetMaterial , "emissiveTexture" ) )
538+ if ( HasPropertyButNoTex ( targetMaterial , "baseColorTexture" ) )
535539 {
536540 propertyList . RemoveAll ( x => x . name . StartsWith ( "baseColorTexture" , StringComparison . Ordinal ) && x . name != "baseColorTexture" ) ;
537541 }
538- if ( HasPropertyButNoTex ( targetMaterial , "normalTexture" ) )
542+ if ( HasPropertyButNoTex ( targetMaterial , "metallicRoughnessTexture" ) )
543+ {
544+ propertyList . RemoveAll ( x => x . name . StartsWith ( "metallicRoughnessTexture" , StringComparison . Ordinal ) && x . name != "metallicRoughnessTexture" ) ;
545+ }
546+ if ( HasPropertyButNoTex ( targetMaterial , "normalTexture" ) )
547+ {
548+ propertyList . RemoveAll ( x => x . name . StartsWith ( "normalTexture" , StringComparison . Ordinal ) && x . name != "normalTexture" ) ;
549+ }
550+ if ( HasPropertyButNoTex ( targetMaterial , "emissiveTexture" ) )
551+ {
552+ propertyList . RemoveAll ( x => x . name . StartsWith ( "emissiveTexture" , StringComparison . Ordinal ) && x . name != "emissiveTexture" ) ;
553+ }
554+ if ( HasPropertyButNoTex ( targetMaterial , "normalTexture" ) )
539555 {
540556 propertyList . RemoveAll ( x => x . name == "normalScale" ) ;
541557 }
542- if ( ! currentMaterialInfo . hasUV0 && ! currentMaterialInfo . hasUV1 )
558+ if ( currentMaterialInfo . hasMesh && ! currentMaterialInfo . hasUV0 && ! currentMaterialInfo . hasUV1 )
543559 {
544560 // hide all texture properties if no UVs
545561 propertyList . RemoveAll ( x => x . name . Contains ( "texture" ) ) ;
546562 }
547- if ( ! currentMaterialInfo . hasUV1 && currentMaterialInfo . occlusionTextureTexCoord == 0 && currentMaterialInfo . baseColorTextureTexCoord == 0 )
563+ if ( currentMaterialInfo . hasMesh && ! currentMaterialInfo . hasUV1 && currentMaterialInfo . occlusionTextureTexCoord == 0 && currentMaterialInfo . baseColorTextureTexCoord == 0 )
548564 {
549565 propertyList . RemoveAll ( x => x . name . EndsWith ( "TextureTexCoord" , StringComparison . Ordinal ) ) ;
550566 }
0 commit comments