Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

*don't* import materials by default

Discussion in 'Editor & General Support' started by GfK, Mar 8, 2015.

  1. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    To cut a long post short - is there any way I can set Unity 5 to NOT import materials by default?

    Checked out my Subversion repository recently to my laptop, and the automatic re-import recreated a bunch of materials that I'd already moved somewhere else. Rather than manually set each FBX model to not import materials, it'd be nice if I could just stop it happening globally.
     
  2. Spellbound

    Spellbound

    Joined:
    Sep 9, 2011
    Posts:
    51
    I'd wish there would be global options for all this stuff in Unity's preference settings.

    We solved this using an AssetPostprocessor script:

    Code (csharp):
    1.  
    2. public class CustomImportSettings : AssetPostprocessor
    3. {
    4.     ModelImporter importer = assetImporter as ModelImporter;
    5.     importer.importMaterials   = false;
    6.     importer.importAnimation   = false;
    7.     importer.importBlendShapes   = false;
    8.     importer.animationType = ModelImporterAnimationType.None;
    9. }
    10.  
    This is a simplified version of how we set up asset post processing. Usually we take the asset path (importer.assetPath) and check subfolders or asset name token to set different import options.
     
    the_motionblur likes this.
  3. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    Thanks - sounds feasible.

    Thing is I'm almost a complete Unity noob - where exactly do I put that script?
     
  4. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    Indeed. Global settings for this would be really welcome and I think are even a little over-due.
     
  5. Spellbound

    Spellbound

    Joined:
    Sep 9, 2011
    Posts:
    51
    You must create or use an existing "Editor" folder in your Assets path. Then save the following script ie. as "NoFBXMaterials.cs" to the editor folder.

    Code (csharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. public class NoFBXMaterials : AssetPostprocessor
    5. {
    6.    void OnPreprocessModel()
    7.    {
    8.      ModelImporter importer = assetImporter as ModelImporter;
    9.      importer.importMaterials = false;
    10.    }
    11. }
     
    Last edited: Mar 9, 2015
    GfK likes this.
  6. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    Oh excellent - works a treat! Didn't even know about the Editor folder.

    Thanks!