So I had two assets with the same name in one group, not idea how this happened - I assume due to some upgrade issues.
When I tried to build the assets I got this:
After some digging it turned out it was due to those duplicated names. This should be validated somehow before the build to give some more meaningful error.
Another issues is, after recent upgrades (I’m @1.4), the changes to load path for Asset Bundle Schema are not persisted in schema file. I need to change this directly in the file for it to persist.
I have this same error - i am trying to locate what that key belongs to - would be nice to have the name associated to that key - gonna dig through some files
Thanks for letting us know. we intentionally support giving different assets the same address. The general use case is you might give two assets the address “tank_texture” but then give them different labels (“hd”, “sd”). Which can ease loading.
So, why did your example blow up? Turns out it has to do with choosing “pack separately” on the group. If you do pack together, your build will work. With the separate option, we try to name the bundle after the asset’s address. I’m putting a ticket in our backlog to fix this by detecting the issue and changing the bundle name.
Note that our “fix” will not detect or disallow duplicate names.
Thank you for the info. Unfortunately, the pack together option (as I understand it) would bunch all the assets into one file. This defeats one of the key use cases for addressables (separating asset files out so they can be easier patched by the underlying distribution platforms).
@unity_bill Can you make sure to put that part in? Knowing the offending key location/asset is critical for us with massive projects. Otherwise, it’s a crapshoot to guess what asset it is.
Here’s a very simple analyze rule that will show you any duplicate addressable names in your groups.
Put it in an editor folder, open the Addressables Analyze window and select Unfixable Rules → Check Duplicate Addressable Names.
Edit: put in the string fix from AutumnYard below.
using System.Collections.Generic;
using UnityEditor.AddressableAssets.Settings;
namespace UnityEditor.AddressableAssets.Build.AnalyzeRules
{
[InitializeOnLoad]
class RegisterAnalyzeDuplicateAddressableNames
{
static RegisterAnalyzeDuplicateAddressableNames()
{
AnalyzeSystem.RegisterNewRule<AnalyzeDuplicateAddressableNames>();
}
}
class AnalyzeDuplicateAddressableNames : AnalyzeRule
{
//--------------------------------
public override bool CanFix
{
get { return false;}
}
public override string ruleName
{
get { return "Check Duplicate Addressable Names"; }
}
//--------------------------------
public override List<AnalyzeResult> RefreshAnalysis(AddressableAssetSettings settings)
{
List<AnalyzeResult> results = new List<AnalyzeResult>();
HashSet<string> addressable_names = new HashSet<string>();
for (int i = 0; i < settings.groups.Count; ++i)
{
AddressableAssetGroup group = settings.groups[i];
foreach (AddressableAssetEntry entry in group.entries)
{
// ToLower fix from AutumnYard
string entry_add = entry.address.ToLower();
if (addressable_names.Contains(entry_add))
{
AnalyzeResult r = new AnalyzeResult();
r.resultName = $"{group.name}:{entry_add}";
r.severity = MessageType.Warning;
results.Add(r);
}
else
{
addressable_names.Add(entry_add);
}
}
}
return results;
}
public override void FixIssues(AddressableAssetSettings settings)
{
base.FixIssues(settings);
}
public override void ClearAnalysis()
{
base.ClearAnalysis();
}
//--------------------------------
}
}
It would really really really help us if we could pick for the “Simplify Addressable Names” to ignore the extension. Most of our duplicates came from our naming conventions of materials, textures, fbx and other stuff often sharing the same name.
By the way, I just noticed why, even after making sure there were no duplicates in the Addressable Names list, there was still the error. Bundle name generation is all lowercase.
I found out printing the variable assetBundleName in the file “Library\PackageCache\com.unity.addressables@1.6.2\Editor\Build\DataBuilders\BuildScriptPackedMode.cs”, when the Add method throws an exception.
The bundle naming generation is all in lowercase, so ThomasBowker code should be all in lowercase to add false negatives to the checking: