Skip to content

Commit

Permalink
Fixed bundleID bug where file name and folder name matched
Browse files Browse the repository at this point in the history
  • Loading branch information
devyndamonster committed Mar 20, 2022
1 parent 88b5f6c commit 6d662ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
18 changes: 14 additions & 4 deletions Scripts/Loaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public static Texture2D LoadTexture(FileSystemInfo file)
return null;
}

private string BuildBundleID(string bundlePath, string bundleName)
{
string directoryPath = Path.GetDirectoryName(bundlePath) + "\\";
return directoryPath + " : " + bundleName;
}


public void LoadDirectAssets(CoroutineStarter starter, string folderPath, string guid, string[] dependancies, string[] loadFirst, string[] loadAny, string[] loadLast)
{
Expand Down Expand Up @@ -136,7 +142,7 @@ public IEnumerator StartAssetLoad(FileSystemInfo handle, LoadOrderType loadOrder
{
FileInfo file = handle.ConsumeFile();

string bundleID = file.FullName.Replace(file.Name, "") + " : " + file.Name;
string bundleID = BuildBundleID(file.FullName, file.Name);

return LoadAssetsFromPathAsync(file.FullName, bundleID, "", new string[] { }, loadOrder, allowUnload).TryCatch(e =>
{
Expand All @@ -155,7 +161,7 @@ public IEnumerator StartAssetLoadDirect(string folderPath, string bundleName, st
string bundlePath = Path.Combine(folderPath, bundleName);
string lateName = "late_" + bundleName;
string latePath = Path.Combine(folderPath, lateName);
string bundleID = bundlePath.Replace(bundleName, "") + " : " + bundleName;
string bundleID = BuildBundleID(bundlePath, bundleName);
IEnumerator afterLoad = null;

if (File.Exists(latePath))
Expand Down Expand Up @@ -184,7 +190,8 @@ public IEnumerator RegisterAssetLoadLate(FileSystemInfo handle, LoadOrderType lo
public IEnumerator RegisterAssetLoadLate(string bundlePath, string bundleName, LoadOrderType loadOrder)
{
//In order to get this bundle to load later, we want to replace the file path for the already loaded FVRObject
string bundleID = bundlePath.Replace(bundleName, "") + " : " + bundleName.Replace("late_", "");
string originalBundleName = bundleName.Replace("late_", "");
string bundleID = BuildBundleID(bundlePath, originalBundleName);
OtherLoader.ManagedBundles[bundleID] = bundlePath;
LoaderStatus.TrackLoader(bundleID, loadOrder);

Expand All @@ -208,6 +215,7 @@ public IEnumerator RegisterAssetLoadLate(string bundlePath, string bundleName, L
else
{
OtherLogger.LogError("Tried to register bundle to load later, but pre-bundle had not yet been loaded! (" + bundleID + ")");
Debug.Log("Bundles: " + string.Join(", ", AnvilManager.m_bundles.m_lookup.Keys.ToArray()));
}

yield return null;
Expand Down Expand Up @@ -235,7 +243,8 @@ public void LoadLegacyAssets(CoroutineStarter starter)
continue;
}

string bundleID = bundlePath.Replace(Path.GetFileName(bundlePath), "") + " : " + Path.GetFileName(bundlePath);
string bundleName = Path.GetFileName(bundlePath);
string bundleID = BuildBundleID(bundlePath, bundleName);

IEnumerator routine = LoadAssetsFromPathAsync(bundlePath, bundleID, "", new string[] { }, LoadOrderType.LoadUnordered, true).TryCatch<Exception>(e =>
{
Expand Down Expand Up @@ -314,6 +323,7 @@ private IEnumerator LoadAssetsFromPathAsync(string path, string bundleID, string
else
{
AnvilManager.m_bundles.Add(bundleID, bundle);
Debug.Log("Added bundle to anvil: " + bundleID);
}

OtherLoader.ManagedBundles.Add(bundleID, path);
Expand Down
7 changes: 6 additions & 1 deletion Scripts/Loaders/ItemSpawnerEntryLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ protected override void LoadAsset(UnityEngine.Object asset, string bundleId)
{
UpdateUnlockStatusForItem(spawnerEntry);
RegisterItemIntoMetaTagSystem(spawnerEntry);
convertedSpawnerIDs.Add(AddEntryToLegacySpawner(spawnerEntry));

ItemSpawnerID convertedSpawnerId = AddEntryToLegacySpawner(spawnerEntry);
if(convertedSpawnerId != null)
{
convertedSpawnerIDs.Add(convertedSpawnerId);
}
}
}

Expand Down

0 comments on commit 6d662ad

Please sign in to comment.