Applying texture to all meshparts

I have a script that attempts to apply a texture to an object and all of its meshparts when the object and the texture are imported. It isn’t working because the material isn’t getting set on the MeshRenderer. What is the matter?

Thanks,
Kevin

using UnityEngine;
using UnityEditor;
using System.Collections;

public class OnImport : AssetPostprocessor
{
    void OnPostprocessModel(GameObject g)
    {
        if (g.name.Contains("Scaled")) {
            g.transform.Rotate(-90, 0, 180);
        } 

        if (g.name.Contains("landscape"))
        {
            g.transform.Rotate(-90, 0, 180);

            Transform def = g.transform.GetChild(0);
            Material landscapeMaterial = new Material(Shader.Find("Standard"));
            Texture landscapeTex = (Texture)AssetDatabase.LoadAssetAtPath("Assets/landscape_texture.tiff", typeof(Texture));
            landscapeMaterial.mainTexture = landscapeTex;

            foreach (Transform meshPart in def) {
                Renderer rend = meshPart.GetComponent<Renderer>();
                rend.material = landscapeMaterial;
            }
        }
    }
}

Still stuck on this… I have been washing my head against the wall.

The difference between material and sharedMaterial is also not clear to me.