• 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
1
Question by BenHymers · Oct 04, 2016 at 05:11 AM · assetpostprocessor

Can AssetPostprocessor change *defaults*, just for first import to project, but not override user settings permanently?

If I do something like this:

 public class FixFBXOptions : AssetPostprocessor
 {
     public void OnPostprocessModel(GameObject g)
     {
         // Never import materials by default.
         var modelImporter = assetImporter as ModelImporter;
         modelImporter.importMaterials = false;
     }
 }

... on adding an FBX to the project, it'll have no materials. That's fine and what I want. But if I then click 'import materials' and apply, the checkbox just gets un-checked and no materials are imported. The same thing happens using OnPreprocessModel.

What I really want is a way to run some code to set import options once, on a project member adding the asset to the project for the first time, but for that code to never run again and to let people change the options afterwards. Is that possible using AssetPostprocessor? I don't want to have to write a custom 'add asset to project' dialogue - I imagine that will end up being rather hacky.

Note: this isn't the same as when an instance of Unity sees the file for the first time, so the trick I've seen of checking if the asset database can load the file won't work.

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Canceling an Asset import in an AssetPostProcessor 1 Answer

Why are certain script variable values set in the AssetPostprocessor being lost? 1 Answer

Error building asset bundles in Unity 4.5 1 Answer

Trying to add a custom component inside PostProcessModel() in an AssetPostProcessor, but get a missing script. 1 Answer

what to return from OnAssignMaterialModel? 1 Answer

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