Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 ronronmx · Nov 13, 2011 at 05:19 PM · importassetassetpostprocessor

OnPreprocessModel() override for individual changes???

So I can't figure out a way around this, and even though it has been talked about already, I never found a fix to this problem.

I am using the following code to process my fbx files on import:

 using UnityEditor;
 using UnityEngine;
 
 public class FBXImportSettings : AssetPostprocessor {
 
     void OnPreprocessModel () {
 
         ModelImporter modelImporter = assetImporter as ModelImporter;
 
         modelImporter.globalScale = 1;
         modelImporter.addCollider = true;
         modelImporter.generateAnimations = ModelImporterGenerateAnimations.None;
         modelImporter.normalImportMode = ModelImporterTangentSpaceMode.Import;
 
         Debug.Log("Importing model at: " + assetPath);
     }
 }


Works like a charm except it won't let me manually change settings...every time I change an import setting manually in the FBXImporter options, it reverts it back to the above values when I press 'Apply'.

Is there a way to prevent this from happening?

Thanks for your time and help,
Stephane

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
3
Best Answer

Answer by nschrag · Mar 18, 2012 at 09:31 AM

I'm not sure if there's an official way to do this, but here's a solution that definitely works.

Add a label to any asset where you want to override your AssetPostProcessor's defaults. To add a label, look at the bottom of the inspector for an ellipsis in a little blue button. Click it to add a label, something like "importoverride". Then, do the following in the asset processor script.

 void OnPreprocessModel() {
     List<string> labels = new List<string>(AssetDatabase.GetLabels(assetImporter));
     if(!labels.Contains("importoverride")) {
         // Do default processing behavior
     }
 }

If more advanced behavior were needed, you could add any number of labels to control the import process per asset.

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 ronronmx · Mar 19, 2012 at 11:29 PM 0
Share

Never thought of doing it this way...I completely forgot about labels, and I didn't even know you could access them via code, so thanks a lot for your answer, very helpful! Quick question: How do you "remove" a label? I messed up the name of a label I was adding and want to remove it now :)

Thanks again!

avatar image nschrag · Mar 20, 2012 at 07:43 PM 0
Share

Removing labels is not terribly intuitive. When you click the ellipsis button, the labels on the current asset should appear highlighted in blue. Click on them there to remove them.

avatar image Spikeh · May 05, 2014 at 02:00 PM 0
Share

Excellent work around!

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Create/Edit an AnimatorController using a script 0 Answers

How to look for a material in Assets folder and sub-folders? 1 Answer

How to auto rotate object on FBX import? 1 Answer

Is there a way to stop Unity importing an asset? 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges