Skip to content

fix file bundle name bug #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,6 @@ static IList<IBuildTask> RuntimeDataBuildTasks(string builtinShaderBundleName, s
static void MoveFileToDestinationWithTimestampIfDifferent(string srcPath, string destPath, IBuildLogger log)
{
//Debug.Log( $"{srcPath} -> {destPath}" );

if (srcPath == destPath)
return;

Expand All @@ -1362,6 +1361,7 @@ static void MoveFileToDestinationWithTimestampIfDifferent(string srcPath, string
Directory.CreateDirectory(directory);
else if (File.Exists(destPath))
File.Delete(destPath);

File.Move(srcPath, destPath);
}
}
Expand Down Expand Up @@ -1399,6 +1399,7 @@ void PostProcessBundles(AddressableAssetGroup assetGroup, IBundleBuildResults bu
if (outputName != null)
break;
}

outputBundleNames.Add(string.IsNullOrEmpty(outputName) ? builtBundleNames[i] : outputName);
}
}
Expand Down Expand Up @@ -1447,9 +1448,18 @@ void PostProcessBundles(AddressableAssetGroup assetGroup, IBundleBuildResults bu
string reconstructedBundleName = string.Join("_", deconstructedBundleName, 1, deconstructedBundleName.Length - 1) + ".bundle";
outputBundleNames[i] = ConstructAssetBundleName(assetGroup, schema, info, reconstructedBundleName);
}

dataEntry.InternalId = dataEntry.InternalId.Remove(dataEntry.InternalId.Length - builtBundleNames[i].Length) + outputBundleNames[i];
SetPrimaryKey(dataEntry, outputBundleNames[i], aaContext);


string newPrimaryKey = outputBundleNames[i];
if (assetGroup.GetSchema<BundledAssetGroupSchema>()?.BundleNaming ==
BundledAssetGroupSchema.BundleNamingStyle.NoHash)
{
newPrimaryKey = StripHashFromBundleLocation(newPrimaryKey);
}

SetPrimaryKey(dataEntry, newPrimaryKey, aaContext);

if (!m_BundleToInternalId.ContainsKey(builtBundleNames[i]))
m_BundleToInternalId.Add(builtBundleNames[i], dataEntry.InternalId);
Expand All @@ -1471,6 +1481,7 @@ void PostProcessBundles(AddressableAssetGroup assetGroup, IBundleBuildResults bu
if (assetGroup.GetSchema<BundledAssetGroupSchema>()?.BundleNaming == BundledAssetGroupSchema.BundleNamingStyle.NoHash)
outputBundleNames[i] = StripHashFromBundleLocation(outputBundleNames[i]);


#if UNITY_IOS
var odrSchema = assetGroup.GetSchema<AppleODRSchema>();
if (odrSchema != null)
Expand All @@ -1480,8 +1491,18 @@ void PostProcessBundles(AddressableAssetGroup assetGroup, IBundleBuildResults bu
{
Debug.LogWarning($"ODR Schema build path value is null");
}

targetPath = Path.Combine(schemaPath, Path.GetFileName(targetPath));
AddBundleODR(outputBundleNames[i], targetPath, outputBundleNames[i]);


string odrBundlePath = targetPath;
if (assetGroup.GetSchema<BundledAssetGroupSchema>()?.BundleNaming ==
BundledAssetGroupSchema.BundleNamingStyle.NoHash)
{
odrBundlePath = StripHashFromBundleLocation(targetPath);
}

AddBundleODR(outputBundleNames[i], odrBundlePath, outputBundleNames[i]);
}
#endif

Expand Down Expand Up @@ -1584,6 +1605,7 @@ private void SetPrimaryKey(ContentCatalogDataEntry forLocation, string newPrimar

forLocation.Keys[0] = newPrimaryKey;
m_PrimaryKeyToLocation.Remove(originalKey);

m_PrimaryKeyToLocation.Add(newPrimaryKey, forLocation);

if (!GetPrimaryKeyToDependerLocations(aaContext.locations).TryGetValue(originalKey, out var dependers))
Expand All @@ -1603,7 +1625,7 @@ private void SetPrimaryKey(ContentCatalogDataEntry forLocation, string newPrimar
}
}
}

m_PrimaryKeyToDependers.Remove(originalKey);
m_PrimaryKeyToDependers.Add(newPrimaryKey, dependers);
}
Expand Down