Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ModelImporter.SearchAndRemapMaterials

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public method SearchAndRemapMaterials(nameOption: ModelImporterMaterialName, searchOption: ModelImporterMaterialSearch): bool;
public bool SearchAndRemapMaterials(ModelImporterMaterialName nameOption, ModelImporterMaterialSearch searchOption);

Parameters

nameOption The name matching option.
searchOption The search type option.

Returns

bool Returns true if the materials have been successfly remapped, otherwise false.

Description

Search the project for matching materials and use them instead of the internal materials.

Unity uses the naming convention specified by nameOption to find and match Material assets in your project and maps them to the model. Use the search option to specify if you want the search to be done project wide, locally or recursive up from the model's location.

no example available in JavaScript
using UnityEditor;

public class MaterialRemapper : AssetPostprocessor { void OnPreprocessModel() { ModelImporter modelImporter = assetImporter as ModelImporter; modelImporter.SearchAndRemapMaterials(ModelImporterMaterialName.BasedOnMaterialName, ModelImporterMaterialSearch.Everywhere); } }

Did you find this page useful? Please give it a rating: