Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Bug Unity made full project reimport on every small change

Discussion in '2020.2 Beta' started by Jes28, Mar 1, 2021.

  1. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    953
    Just updated to Unity 2020 and already have reimported project about 5 times because every project chnage fires project reimport (all textures and meshes got reimported)

    - Update Unity - got reimport
    - Update URP - got reimport
    - Update TextMesh Pro package - got reimport
    - Added Backery to Project - got reimport
    - Updated Android logcat package - got reimport

    This is very bad workflow of new Unity. Is it known? When UT plan to fix this?
     
    dongch007 likes this.
  2. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    953
    And it looks like Unity AssetDatabase v2 dont work actually because All textures absolutely dont change by any of changes but fully reimported and dont get from already imported AssetDatabase.
     
  3. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    953
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    If some pacakge says "yo, I actually change the logic of how textures are imported, so please pay attention to me!", then a reimport is by design.

    Now, whether the packages you listed do have that logic or not, I don't know. Something like "android logcat" deifnitely sounds like it should not. Something like TextMeshPro might (whether for good reason or not, I don't know).
     
  5. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    25
    https://forum.unity.com/threads/upd...ire-project-to-reimport.1072157/#post-6985475
    https://forum.unity.com/threads/why...eimport-of-all-textures.1065839/#post-6884252
    Seems even TextMeshPro dev dont know why.....
    There's no meta file changed after reimport. And for example delete Bakery or remove ProBuilder also trigger reimport.
    So I guess this is a bug. The same point maybe we all upgrate project from old version. I upgrade from 2017.4 to 2020.2.
    Can I konw which code maybe trigger reimport? Maybe I can search code to see where triggered.
     
  6. volblob73

    volblob73

    Unity Technologies

    Joined:
    Sep 19, 2017
    Posts:
    29
  7. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    953
    Last time I changed packages it was 2020.2.6f1
    You can see this in bug report
     
  8. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    953
    And reimported prefabs is not a problem for me they all took about 2 minutes
    Issue is reimported textures
     
  9. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    25
    Last edited: Apr 18, 2021
  10. volblob73

    volblob73

    Unity Technologies

    Joined:
    Sep 19, 2017
    Posts:
    29
    I have had a look at this case and it is expected that textures get reimported. In the repo you add ProBuilder and this package is adding a texture preprocessor IconImporter.OnPreprocessTexture(). If you add a texture processor to you project, all textures will get reimported. This is the scenario @Aras described.
     
    dasparadoxon and LeonhardP like this.
  11. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    25
    Ok, I konw what you mean. If there's a new OnPreprocessTexture, all texture should excute this OnPreprocessTexture.
    But IconImporter only process ProBuilder's textures, other texture settings in this project are not modified, they should not do addition compress or any other operators even download from cacheserver.
     
    Jes28 likes this.
  12. volblob73

    volblob73

    Unity Technologies

    Joined:
    Sep 19, 2017
    Posts:
    29
    So it is the presence of a OnPreprocessTexture method that results in a dependency to all textures. It doesn't matter what textures that actually are being process inside the method. Work is being done to improve this, so that an asset processor like OnPreprocessTexture can be configured to only process assets in certain parts of a project.
     
    Jes28 and LeonhardP like this.
  13. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    953
    It will be good to also have fast reimport of textures, like if preprocessors change nothing to texture than do nothing and go to next texture
     
  14. MaxRoetzler

    MaxRoetzler

    Joined:
    Jan 3, 2010
    Posts:
    134
    @volblob73 this behavior has been changed recently, since Unity 2020 something? I don't recall Unity doing this in earlier versions. It used to require triggering a manual reimport to update the asset settings, even with custom asset processors in place. This was a much more preferable workflow than getting hit by random and completely unnecessary reimports! There should at least be an option in the preferences that can be turned off again... It might not be an issue if you work on empty projects, but in the real-world this is incredibly frustrating and a complete waste of time.
     
    guycalledfrank likes this.
  15. volblob73

    volblob73

    Unity Technologies

    Joined:
    Sep 19, 2017
    Posts:
    29
    @MaxRoetzler no this is not something that has changed. Unity has always been tracking pre/post processors as dependencies. It might be that pre/post processors are more likely to change with the introduction of packages.

    In general you always want Unity to do reimports of assets, if a dependency has changed. If a dependency aren't tracked, then your library folder will get into a inconsistent state and your project will likely become broken.

    You can disable auto-refresh to manually control when asset database refresh is done.
     
  16. MaxRoetzler

    MaxRoetzler

    Joined:
    Jan 3, 2010
    Posts:
    134
    @volblob73 Thanks for your answer! I already have auto-refresh disabled, but it doesn't stop Unity from starting reimports of the entire project now and then, when some code gets recompiled, unrelated to any package changes. I assumed it was triggered by a preprocessor, but after checking the files, none of the changes were actually applied during the re-import. Only when I manually re-import the assets it will update the settings, which is how it used to be all along. I'll move my frustration to another thread/bug then.
     
  17. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,551
    Yeah, this really looks like a bug IMHO.
    People have huge projects with multiple hours worth reimporting time. I always thought that asset postprocessors are only called if WHEN the reimport is triggered, but they don't trigger the reimport itself.
    Now I have reviews like this :D

    upload_2021-12-3_23-30-24.png


    It didn't even get to my code - simply blocked the user during package import.

    I also don't remember it happening pre-2020 TBH. Simply creating an asset postprocessor script in the project definitely didn't force project reimport.
     
  18. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,551
    So I decided to check which Unity versions actually reimport the entire project worth of textures when you simply create a script with OnPreprocessTexture:

    5.6: nope.
    2017.4: nope.
    2018.3.3: nope.
    2019.3.4: nope.
    2020.1.2: nope.
    2020.1.14: nope.
    2020.2.2: yes.
    2020.2.7: yes.
    2020.3.2: yes.
    2021.1.7: yes.

    So it looks like a bug/regression that was added somewhere between > 2020.1.14 and <= 2020.2.2.
     
  19. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    My understanding is that this is by design. Existence (or addition/removal of) OnPreprocessTexture could alter the result of texture imports. Thus, whenever you add one, everything gets reimported "to be safe". This was added in Asset Database V2 or somesuch. ADBv1 did not have it, and (I'm told) that was part of the reason why for example using the cache server was "kinda not reliable" with it.

    Yes, this is extremely suboptimal if your newly added texture import processor wants to only affect one texture out of a million. But until Unity gets some way to indicate "you know what, these asset processors only run on these assets", instead of "possibly affecting everything", that is the current state.
     
    dasparadoxon and guycalledfrank like this.
  20. guycalledfrank

    guycalledfrank

    Joined:
    May 13, 2013
    Posts:
    1,551
    Hmm, all previously written scripts were still written assuming old behaviour (e.g. I only care about the new lightmaps being imported after the asset is installed). Perhaps there should be some specific [ReimportAll] tag explicitly set in the script to force the new behaviour? This way both behaviours are possible. But currently old behaviour just suddenly costs a few hours (sometimes days) of reimporting.

    If some scripts actually wanted to re-process all project assets and it wasn't reliable, it seems like a wrong way to solve it. E.g. it could be solved by making the script detect that it was just installed and optionally iterating over all (or not all) assets and reimporting them, then setting some flag somewhere to not repeat it.

    Finally, judging by its name and the docs, OnPreprocessTexture is just a function that "gets a notification just before the texture importer is run". It's a callback, and from the API user perspective it's totally not predictable that it can actually cause some action (not react on action).
     
    Last edited: Dec 12, 2021
    Lars-Steenhoff and Jes28 like this.
  21. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Maybe, I'm just parroting what I've heard from people who are working on asset importing pipeline code :)
     
    guycalledfrank likes this.
  22. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,594
    Is there a hacky way to avoid this project-wide reimport? I mean, is there some sort of "all textures must be reimported" flag somewhere in Library/Temp/etc. that I can manually set to false ( ͡° ͜ʖ ͡°)
     
  23. avataris-io

    avataris-io

    Joined:
    Jun 23, 2020
    Posts:
    23
    We are working on a huge project with a lot of high quality 3d models and textures, having more than 500 GB in the Library folder alone - and with each single changing of anything, including some small scripts that have definitely nothing to do with the here mentioned processes, Unity starts to reimport all.

    Wasting days because of this bug - and it defintitely IS a bug and not normal behavior. I can confirm what guycalledfrank said: This big problems did not exist for older Unity versions, they also had a lot of issues, but definitely not a reimport after each super small and simple script changing.

    Please Unity team focus on improving editor behavior and HDRP performance. You have been losing massively in competitiveness to Unreal for a few years now, because larger projects with higher graphics demands are practically almost impossible to implement. And we really don't want to have to switch. Thank you.
     
  24. DonCornholio

    DonCornholio

    Joined:
    Feb 27, 2017
    Posts:
    81
    I can't say that ANY script change triggers a reimport for me, BUT the fact that changing an AssetPostProcessor script simply triggers a reimport of the whole project is not sensible at all. When i am iterating i need to make changes often and it is completely sufficient for me, to just test with the reimport of a single asset to see if my code works as expected.
    I mean just make a PopUp telling the user: "Hey your Asset Processors have changed do you want to reimport the project" - "Yes" , "Hell No!" . It can't be that hard, i know the people at Unity are incredibly smart people.

    For all you having issues with texture reimports, have you tried setting the editor preference of Compress Assets on Import to false ? I am currently working on a MeshPostProcessor and so i am not sure if this helps in your case but it was very helpful to a lot of my colleagues who only need the texture to compress when actually building. I can also recommend switching to PC Standalone because from my experience DXT compresses A LOT faster than ASTC/ETC2 even though performance has improved significantly from 2019 to 2021. Asset Cache Server would also help a ton but only really works if you're on the same local network or everyone has amazing internet in their home office

    Also with 2021 you can see which Processors are active when you check the import settings of a Texture or Mesh, that might help pin down the a simple script triggers reimport. Maybe the script is part of an assembly def that contains a Processor ?
     
  25. DonCornholio

    DonCornholio

    Joined:
    Feb 27, 2017
    Posts:
    81
    Just for the record: For some reason the issue disappeared again and updating the post processor script no longer triggers a complete reimport. I think there might be a weird bug or something.

    But nevertheless Unity should always give developer the option to postpone a reimport of the whole project - because this is something that Unity is really infamous for and has become a meme at this point.
     
  26. magehuntz

    magehuntz

    Joined:
    Mar 24, 2017
    Posts:
    23
  27. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    132
    This is frustrating. Please let user have a button to Yes / No this whole project reimport. Some asset store asset triggers this on install.
    Polybrush, Animancer Lite, Archimatix. Those are just the one I know, might be much more.
     
  28. wildWind

    wildWind

    Joined:
    Jan 18, 2016
    Posts:
    4
    has the issue been fixed?