• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by jashan · Nov 28, 2009 at 12:21 PM · materialimport

Can I disable automatic creation of materials on model import?

I've posted this on the forum quite a while ago and forgot about it - but as the posting got bumped I thought it's worth a quick q/a over here:

When importing objects, there's materials created automatically which sometimes (e.g. in the case of having lo-poly/hi-poly models) isn't that useful, in particular when you work with modified copies of those models.

So, is it possible - and if so, how - to disable automatic generation of materials?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by jashan · Nov 28, 2009 at 12:25 PM

RTFM ;-) Well, in the current version of Unity (2.6), you find a DropDown in the FBXImporter-section under "Materials" which says either "Off", or "Per Texture" or "Per Material". So that does the trick. Maybe someone could add if there's a way to make this the default (my guess would be that this is possible with editor scripting but there might be an easier way, too).

In this property inspector, you can also disable importing animations.

EDIT: There's also an example of how to disable this always via editor scripting in the scripting reference: AssetPostprocessor.OnPreprocessModel

In C#, this would look something like:

using UnityEditor;

public class MyMeshPostprocessor : AssetPostprocessor { public void OnPreprocessModel() { // Disable generation of materials if the file contains // the @ sign marking it as an animation. if (base.assetPath.Contains("@")) { ModelImporter modelImporter = (ModelImporter) base.assetImporter; modelImporter.generateMaterials = ModelImporterGenerateMaterials.None; } } }

Only problem with this approach: I think it would probably set this to "none" each time the model is reimported which would overwrite manual changes. Anyone has an idea how that could be solved (in an easy manner without having to do our own book-keeping ;-) )?

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jessy · Nov 28, 2009 at 03:19 PM 1
Share

That only works after you have imported the model. It's still going to have the materials generated once. I'd like to know if it's possible to disable that behavior.

http://forum.unity3d.com/viewtopic.php?p=236143#236143

avatar image jashan · Nov 29, 2009 at 11:09 AM 0
Share

I think it should be possible to disable that. The API would be http://unity3d.com/support/documentation/ScriptReference/$$anonymous$$odelImporter-generate$$anonymous$$aterials.html - however, since I haven't done a lot of editor scripting, I'm not sure how to make sure this is set directly on the first import (before actually doing the import); so maybe someone who knows better can chime in. Ah: Should work with: http://unity3d.com/support/documentation/ScriptReference/AssetPostprocessor.html - there you have OnPreprocess$$anonymous$$odel and ... haha - the solution is in the example, I'll edit my answer to include this.

avatar image Cyclops · May 01, 2010 at 02:35 PM 1
Share

$$anonymous$$an, that's cold, telling this poor guy to RTF$$anonymous$$... wait...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

importing a blender model amd making it look the same 0 Answers

How NOT to create redundant materials with new names on import? 2 Answers

Import Material from filepath? 1 Answer

Texture Discoloration Issue When Importing Into Unity 1 Answer

Import and Material Question 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges