Summary: Apparently, the assets in our cache server have asset bundle tags and this is confusing Unity when these cached tags conflict with the tags in the .meta files. If I reimport assets or delete Library and restart without connecting to out cache server, the problem does not appear.
So, I was in a situation where calling AssetImporter.GetAtPath(path).assetBundleName would give me a non-empty name, but AssetDatabase.GetAssetPathsFromAssetBundle(importer.assetBundleName).Length == 0
This meant that even though the UI did not show any assets as tags with bundles, and none of the .meta files contained any mention of bundles, the importer.assetBundleName would still claim the asset was assigned to a bundle. This is after restarting with an emptied Library folder.
Fortunately, the bundle names were consistent with what I wanted them to be. I think they were cached from an earlier experiment in auto-assigning bundle names. So, I ran my auto-assign script again, and…
Now the .meta files say they are tagged with bundles, the AssetImporters think they are tagged, but the UI and GetAssetPathsFromAssetBundle still think that they are not!
They say there are only two hard problems in computer science. I’m just trying to solve the problem of naming things. But, I need Unity to solve the problem of cache invalidation for themselves.
I don’t think I can upload a repro project for this one. Not unless there’s some way to upload the state of the cache server…
Which version of Unity are you using? There is bug at Cache server with AssetBundle tag. We fixed in 5.2, also back ported to 5.0 and 5.1 patch releases.
Actually, I take that back. I am seeing a variation of the bug again. I am using 5.1.2f1. A big difference is that previously, the AssetBundle tag in the editor would display as blank instead of “None” or a bundle name. Now the UI displays the tag correctly, the .meta file contains the tag correctly, but the assets are sometimes not included in the bundles anyway. AssetDatabase.GetAssetPathsFromAssetBundle() does not report all of the assets that are tagged for that bundle and the manifest for the bundle shows that some assets are not included.
The sequence of events that led to this for me was:
An artist created an asset without assigning a bundle tag. It was uploaded to the cache server and to source control.
I synched the project from source control and thereby synched the asset from the cache server
I ran a script to assign a bundle tag to the asset via the AssetImporter interface
Now the UI and the .meta files show the assets as tags with bundles, but after rebuilding the bundles, those bundles still do not include those new assets.
If I locally reimport the new asset, then the asset does start to be included in it’s bundle. Deleting Library and resynching from the cashe server does not fix the problem.
Also, the problem is definitely the cache server. If I disconnect from the cache server, close the editor, delete Library, reopen the editor, then there are no errors after the long import process.