Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

How to verify texture imported as normal map?

Discussion in 'Extensions & OnGUI' 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,130
  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:
    31
    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)