How to verify texture imported as normal map?

I’m writing a custom Editor for a ScriptableObject, and one of the fields I have is for a normal map. I’d like to check that the texture was imported with the Texture Type set to Normal Map, just like the Material inspector does for the normal map field in the Standard shader.

However, the field I have gets a Texture2D, and it is not clear to me how to get the texture type the importer used from the Texture2D.

How can I verify the texture dropped in my EditorGUILayout.ObjectField was imported as a normal map?

var importer = (TextureImporter)AssetImporter.GetAtPath("Assets/texture.tga");
Debug.Log(importer.textureType);

AssetImporter.GetAtPath
https://docs.unity3d.com/ScriptReference/AssetImporter.GetAtPath.html

TextureImporter.textureType
https://docs.unity3d.com/ScriptReference/TextureImporter-textureType.html

Thanks Peter. AssetImporter.GetAtPath plus AssetDatabase.GetAssetPath got me from Texture2D to TextureImporter.

Hi,
Is there anyway to restrict the field to normal map only? For example:

    [CreateAssetMenu(fileName = "MyData", menuName = "Custom/MyData", order = 1)]
    public class MyData : ScriptableObject
    {
        [SerializeField]
        private Texture2D[] m_arrBumpMaps; //How to restrict this field to Normal map only (in case I forgot to import it as Normal map)

One way you might restrict a Texture2D field in the inspector to only being normal maps is by using the OnValidate() method of MonoBehaviour or ScriptableObject. In that method you could get the TextureImporter and check if its textureType is set to normal map. If not, you could set it to null or log an error or log a warning, whatever you want.