Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by anszwa · Mar 26, 2020 at 10:12 AM · importing assetsassetdatabaseimport modelpreprocessorimport settings

Only PreProcess assets on first import.

hey folk,

i have the issue, that a beloved utility script of mine, which i used for years now, stops working as expected. i use an editor script which deactivates a lot of, for my project, unneeded components from models at first import. for example:

 private void OnPreprocessModel() 
 {
     ModelImporter importer = assetImporter as ModelImporter;
     Object asset = AssetDatabase.LoadAssetAtPath (importer.assetPath, typeof(Object));
     
     if (!asset)
     {
         importer.materialImportMode = ModelImporterMaterialImportMode.None;
         importer.animationType = ModelImporterAnimationType.None;
     
         importer.importAnimation = false;
     
         Debug.Log("Model Import: override import settings for: " + importer.assetPath);
     }
 }

the pre processor gets always called if a model is imported or reimported, by changing its settings for example. now my issue is, that the old way of asking if the model is new, or already exists in the asset database, doesnt work anymore with the current unity version.

in older versions the asset variable in the example got only assigned, if the asset already exists, so the if statement was only executed at new imports. now, it is always assigned, so every time i change a setting, override a model, or switch platform, it have to execute the hole function, otherwise it would never be called.

ot i have tried a couple of different things, like asking, if there is already a meta file, but it seams that the new unity version creates this all before preprocession now.

here are some sources on how it works back in the days: https://answers.unity.com/questions/654816/only-postprocesspreprocess-on-new-assets.html

https://forum.unity.com/threads/first-asset-import.136393/

long story short, how can i differ between new and already existing models at import?

thank you for your time reading this and it would be great if you could help me out with this!

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

Answer by mikelortega · Oct 20, 2020 at 02:49 PM

You can detect the first import with AssetImporter.importSettingsMissing

Checking if (importer.importSettingsMissing) will return true the fist time a model is imported, false once it's been imported and future reimports.

Comment
Add comment · Show 1 · 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 anszwa · Dec 14, 2020 at 07:57 PM 0
Share

haven´t been here for a while, but here my late thanks!

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

124 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Imported model looks weird. 1 Answer

How can I get Unity to respect mcs.rsp changes between multiple builds? 0 Answers

Bug: Broken 2D PSB Models after upgrading Unity from 2019.3.7f1 to 2019.4 LTS 0 Answers

Adding primitive collider to armature from imported blender model issue 0 Answers

Why can't I change anisotropic level in a 2D sprite's import settings? 3 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