Home Unity

Help re: importing materials

polycounter lvl 7
Offline / Send Message
KateC polycounter lvl 7
Hi PC,

The animator I've been working with asked me about material workflow today - I feel like this is such a basic question on the one hand, but I'm not sure how to elegantly answer it for her.

"...there are a bunch of extra materials associated with my animation files that get imported every time I bring in a new animation. Is there a way to map the unity material to the models in Maya to avoid importing all these extra
files?"

Everyone has game engine blind spots, and I think this is mine!

Replies

  • Frankie
    Offline / Send Message
    Frankie polycounter lvl 20
    Every time you import an asset with mesh data unity makes some materials based on images assigned to mesh or material name (I always find it slightly confusing and unpredictable).

    Sounds like every time she imports an animation it has mesh data in so new materials are being created.

    On selecting the asset in the project view there is a tick box for "import materials" that appears in the inspector, you will probably find the solution there. Having said that, it will generate the materials the first time you import the asset before you have a chance to change the default settings.

    I think its possible to have a script to do it automatically based on folder or name (kind of like this http://forum.unity3d.com/threads/can-i-change-the-default-import-settings.50043/ ) but I'm not sure how sorry, maybe one of your programmers could make it work.
  • Farfarer
    There are settings on the model in the Inspector that determine how Unity names the materials and how it searches for them. I think it's also possible to tell it not to import any materials at all.
  • MikeF
    Offline / Send Message
    MikeF polycounter lvl 20
    By default unity will name materials based on the diffuse property of the exported material. I use this script so that all the names are the same as the material names inside of maya, this way any texture changes wont create new materials

    create a new .js file and place this in a folder at the root of your project called "Editor"

    class CustomImportSettings extends AssetPostprocessor {

    function OnPreprocessModel() {
    var importer : ModelImporter = assetImporter as ModelImporter;
    importer.materialName = ModelImporterMaterialName.BasedOnMaterialName;
    }
    }
  • KateC
    Offline / Send Message
    KateC polycounter lvl 7
    Thanks so much, all! Appreciate the advice.
  • echofourpapa
    Offline / Send Message
    echofourpapa polycounter lvl 4
    Another option, if it's just animations, to only export the rig and animations, not the mesh itself. This way FBXs with only animation data will never generate materials.
Sign In or Register to comment.