-
Notifications
You must be signed in to change notification settings - Fork 4
Description
ToDynamicAsset() method uses a static dictionary via GetDeserializer() that indexes deserializers based on hashes of ScriptIDs, but then loading slightly different types with the same hash can cause an error. (For me, this happens when opening analogous AssetBundleFiles from different versions of the same program.) It appears that assets within the same version of an application don't have any overlaps in hashes, but there are collisions with different types between different versions. (See, for instance, the attached test project.) While exceptions are thrown sometimes when this happens, it may be that others fail silently.
This can be mitigated by calling GenDeserializer directly rather than using GetDeserializer (or, therefore, ToDynamicAsset), but this of course gets rid of the benefit of the cache. Rather than making this a static method (and static dictionary), would it be preferable to make it a property of the AssetBundleFile so that loading different assetbundles would not result in these errors? Another possibility would be the addition of a method to "reset" the static dictionary when necessary to load a different version that may have overlapping hashes.