Search Unity

Cant use Unity 5 AssetDatabase.ImportAsset with Cache Server

Discussion in 'Asset Database' started by CharlesBarros, Apr 1, 2015.

  1. CharlesBarros

    CharlesBarros

    Joined:
    Nov 17, 2011
    Posts:
    61
    Our build flow uses the method AssetDatabase.ImportAsset to create asset bundles with different texture compressions and sizes.
    We built the whole project and triggered a new build to test the cache server. Unfortunately there was no difference in the duration of the build. It's a large project and the build asset bundles process take up to 4 hours.
    In fact, all changes made by the AssetDatabase.ImportAsset are followed by this message in the editor.log:
    "Not using cache server because the importer is dirty"

    It's weird because the cache server has this asset and we are not using the flag "DontDownloadFromCacheServer" in the AssetDatabase.ImportAsset. We tried all other flags as well without success.

    It's even more weird because if we change the texture settings using the inspector, after hitting apply the asset is correctly download from cache server. So I don't think that its a problem of the cache server.

    Is there a way to use the same behaviour of the texture import settings inspector's "Apply" button?
     
  2. CharlesBarros

    CharlesBarros

    Joined:
    Nov 17, 2011
    Posts:
    61
    Fixed.
    Use AssetDatabase.WriteImportSettingsIfDirty instead of AssetDatabase.ImportAsset or TextureImporter.SaveAndReimport... but I still think that the other methods should work.
    It might be a bug? Should I open an issue in the bug tracker?
     
  3. CharlesBarros

    CharlesBarros

    Joined:
    Nov 17, 2011
    Posts:
    61
    In fact there is something weird... The solution that I posted above works in Unity Windows but does not work in Unity Mac.

    If I use the AssetDatabase.WriteImportSettingsIfDirty in Unity Mac, the texture settings are not applied. Instead it became uncompressed and the following text appears in the inspector: "Texture not compressed yet".
     
  4. TheGamedevGuru

    TheGamedevGuru

    Joined:
    Jun 3, 2015
    Posts:
    10