Data file imported twice resulting in an exception
See original GitHub issueHi, I’ve found this awesome tool just yesterday and was trying to rip one game but I always got this exception in the output log:
Import: System.ArgumentException: SerializedFile with name 'globalgamemanagers' already presents in the collection
So I cloned the repo to investigate what’s going on as I thought it may be a bug in UtinyRipper rather than in the game itself and found out, that the data.unity3d
file is being imported twice and that results in the above exception.
I was able to find out where exactly, and why that happens:
When an instance of uTinyRipper.PCGameStructure
is created, it looks for files to import:
Dictionary<string, string> files = new Dictionary<string, string>();
CollectGameFiles(dataDirectory, files);
CollectStreamingAssets(dataDirectory, files);
Files = files;
The CollectGameFiles
method first looks specifically for a file with the name data.unity3d
. If it finds it, the info about that file is added to the dictionary. So far, so good. But when we go to the next method - CollectAssetBundles
, it looks for every file with the .unity3d
extension adding the data.unity3d
file to the dictionary again but now without an extension as the key. What we get is this (the blacked-out paths are exactly the same):
I was able to work-around this bug by modifying the condition inside the CollectAssetBundles
method changing it like so:
if (file.Extension == AssetBundleExtension) // original
if (file.Name != "data.unity3d" && file.Extension == AssetBundleExtension) // with workaround
But I don’t know if this’s the best solution so I let you to decide how to fix this 😄
Another possible solution would be to call the Distinct
LINQ extension method on the dictionary, probably with custom equality comparer, after it’s created to remove any possible duplicates that may be created somewhere else.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Fixed in e1dab38e73264b45bf64236bf1e05686e96459c1
Works perfectly. Thanks!