Search Unity

How to verify texture imported as normal map?

Discussion in 'Immediate Mode GUI (IMGUI)' started by DougRichardson, Oct 24, 2017.

  1. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    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?
     
  2. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    3,711
  3. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    Thanks Peter. AssetImporter.GetAtPath plus AssetDatabase.GetAssetPath got me from Texture2D to TextureImporter.
     
  4. NathanJSmith

    NathanJSmith

    Joined:
    May 11, 2018
    Posts:
    49
    Hi,
    Is there anyway to restrict the field to normal map only? For example:
    Code (CSharp):
    1.     [CreateAssetMenu(fileName = "MyData", menuName = "Custom/MyData", order = 1)]
    2.     public class MyData : ScriptableObject
    3.     {
    4.         [SerializeField]
    5.         private Texture2D[] m_arrBumpMaps; //How to restrict this field to Normal map only (in case I forgot to import it as Normal map)