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.

On demand material remap & multiple selection

Discussion in 'Editor & General Support' started by EiknarF, Oct 29, 2019.

  1. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    135
    Hi.

    How do I use on demand material remap with multiple selections?

    I have 100s of fbx files that all share the same materials. I really don't want to do each one individually.

    Only work around I have found is a find and replace inside the meta files.

    Thanks
     
  2. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    135
    Bump because I would really like to know
     
  3. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    135
  4. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    135
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. public class MaterialLocationAssetPostprocessor : AssetPostprocessor
    7. {
    8.     void OnPreprocessModel()
    9.     {
    10.         var importSettingsMissing = assetImporter.importSettingsMissing;
    11.  
    12.         if (!importSettingsMissing)
    13.             return; // Asset imported already, do not process.
    14.  
    15.         var modelImporter = assetImporter as ModelImporter;
    16.         modelImporter.SearchAndRemapMaterials(ModelImporterMaterialName.BasedOnMaterialName, ModelImporterMaterialSearch.Everywhere);
    17.     }
    18. }
    19.  
     
    lvlzro likes this.
  5. LoSmX

    LoSmX

    Joined:
    May 19, 2021
    Posts:
    1
    Hi,
    I found a solution for my problem I hope it is applyable to yours as well.
    When it is about not seeing textures of fbx files you my try reseting the import by goint to the materials tab clicking on the tree dots and reset.This loaded my embedded textures.

    upload_2022-11-22_18-46-54.png
     

    Attached Files: