Update file setup for addressable remote
This commit is contained in:
@@ -67,7 +67,7 @@ namespace BrewMonster.Scripts
|
||||
await LogLabelLookupAsync(sb, wrongCase, 2, suffix: " [wrong case]");
|
||||
}
|
||||
|
||||
await LogAllCatalogLabelsAsync(sb, label);
|
||||
LogAllCatalogKeys(sb, label);
|
||||
|
||||
sb.AppendLine($"{LogPrefix} Ghi chú: Label trong Addressables Groups ≠ file trên CDN. " +
|
||||
"CDN có catalog_*.json + bundle; label nằm TRONG catalog JSON sau khi build. " +
|
||||
@@ -133,63 +133,77 @@ namespace BrewMonster.Scripts
|
||||
}
|
||||
}
|
||||
|
||||
static async UniTask LogAllCatalogLabelsAsync(StringBuilder sb, string highlightLabel)
|
||||
/// <summary>
|
||||
/// Addressables 2.7 has no runtime GetLabels(); enumerate string keys from loaded locators instead.
|
||||
/// Keys include both labels and asset addresses.
|
||||
/// </summary>
|
||||
static void LogAllCatalogKeys(StringBuilder sb, string highlightLabel, int maxKeysToLog = 80)
|
||||
{
|
||||
AsyncOperationHandle<IList<string>> handle = default;
|
||||
try
|
||||
var keys = new List<string>();
|
||||
var seen = new HashSet<string>(StringComparer.Ordinal);
|
||||
|
||||
if (Addressables.ResourceLocators != null)
|
||||
{
|
||||
handle = Addressables.GetLabels();
|
||||
await handle.ToUniTask();
|
||||
|
||||
if (handle.Status != AsyncOperationStatus.Succeeded)
|
||||
foreach (IResourceLocator locator in Addressables.ResourceLocators)
|
||||
{
|
||||
sb.AppendLine($"{LogPrefix} GetLabels() failed: {handle.OperationException?.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
var labels = handle.Result;
|
||||
int n = labels?.Count ?? 0;
|
||||
sb.AppendLine($"{LogPrefix} GetLabels() → {n} label(s) in loaded catalog(s):");
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
sb.AppendLine($"{LogPrefix} (empty — catalog build cũ hoặc chưa có remote catalog)");
|
||||
return;
|
||||
}
|
||||
|
||||
bool foundHighlight = false;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var l = labels[i];
|
||||
if (string.IsNullOrEmpty(l))
|
||||
if (locator?.Keys == null)
|
||||
continue;
|
||||
|
||||
bool match = string.Equals(l, highlightLabel, StringComparison.Ordinal);
|
||||
bool matchIgnoreCase = string.Equals(l, highlightLabel, StringComparison.OrdinalIgnoreCase);
|
||||
if (match)
|
||||
foundHighlight = true;
|
||||
|
||||
string flag = match ? " <-- EXACT MATCH" :
|
||||
matchIgnoreCase ? " <-- same letters, different case" : "";
|
||||
sb.AppendLine($"{LogPrefix} [{i}] \"{l}\"{flag}");
|
||||
foreach (object key in locator.Keys)
|
||||
{
|
||||
if (key is not string s || string.IsNullOrEmpty(s) || !seen.Add(s))
|
||||
continue;
|
||||
keys.Add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundHighlight)
|
||||
keys.Sort(StringComparer.Ordinal);
|
||||
int n = keys.Count;
|
||||
sb.AppendLine(
|
||||
$"{LogPrefix} ResourceLocator keys → {n} unique (labels + addresses; Addressables 2.7 has no GetLabels()):");
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
sb.AppendLine($"{LogPrefix} (empty — catalog build cũ hoặc chưa có remote catalog)");
|
||||
return;
|
||||
}
|
||||
|
||||
bool foundHighlight = false;
|
||||
bool foundHighlightIgnoreCase = false;
|
||||
int logCount = Mathf.Min(maxKeysToLog, n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var k = keys[i];
|
||||
bool match = string.Equals(k, highlightLabel, StringComparison.Ordinal);
|
||||
bool matchIgnoreCase = string.Equals(k, highlightLabel, StringComparison.OrdinalIgnoreCase);
|
||||
if (match)
|
||||
foundHighlight = true;
|
||||
if (matchIgnoreCase)
|
||||
foundHighlightIgnoreCase = true;
|
||||
|
||||
if (i >= logCount)
|
||||
continue;
|
||||
|
||||
string flag = match ? " <-- EXACT MATCH" :
|
||||
matchIgnoreCase ? " <-- same letters, different case" : "";
|
||||
sb.AppendLine($"{LogPrefix} [{i}] \"{k}\"{flag}");
|
||||
}
|
||||
|
||||
if (n > logCount)
|
||||
sb.AppendLine($"{LogPrefix} … {n - logCount} more key(s) omitted (maxKeysToLog={maxKeysToLog}).");
|
||||
|
||||
if (!foundHighlight)
|
||||
{
|
||||
sb.AppendLine(
|
||||
$"{LogPrefix} WARNING: \"{highlightLabel}\" NOT in catalog keys — " +
|
||||
"InvalidKeyException khi GetDownloadSizeAsync/DownloadDependencies là đúng.");
|
||||
if (foundHighlightIgnoreCase)
|
||||
{
|
||||
sb.AppendLine(
|
||||
$"{LogPrefix} WARNING: \"{highlightLabel}\" NOT in GetLabels() list — " +
|
||||
"InvalidKeyException khi GetDownloadSizeAsync/DownloadDependencies là đúng.");
|
||||
$"{LogPrefix} (có key cùng chữ khác hoa/thường — label Addressables phân biệt hoa thường)");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
sb.AppendLine($"{LogPrefix} GetLabels() exception: {e.GetType().Name}: {e.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (handle.IsValid())
|
||||
Addressables.Release(handle);
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsRemoteLocation(IResourceLocation loc)
|
||||
|
||||
Reference in New Issue
Block a user