Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [2.2.2] - 2024-06-26
- Fix KeyNotFoundException when clicking on local bundles in the profiler.
- Fix bundles incorrectly marked as released in the Profiler when they are still active
- Improved error message when trying to load a catalog in an unexpected file format.
- Fixed issue where operation that uses WaitForCompletion can timeout much earlier than it should.
- The build scripts were reworked so that you can extend them or copy them outside the package without having to fork the entire package.
- A Version field was added to the Addressables object for getting the package version in the Editor.
- Fixed an issue where tearing down the Addressables instance could happen before user tear down code was getting called.
- Sort collections to make serialized editor files deterministic
- Fixed issue where labels on an addressable sub-entry are incorrectly added to the former parent entry.
- Added support for calling Release() on AsyncOperationHandles directly that couldn't before.
- Fixed sub-object loading from AssetReferences for types that are not Sprites in a SpriteAtlas.
  • Loading branch information
Unity Technologies committed Jun 26, 2024
1 parent 45b4451 commit 580b2db
Show file tree
Hide file tree
Showing 116 changed files with 2,438 additions and 1,963 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,24 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.2.2] - 2024-06-26
- Fix KeyNotFoundException when clicking on local bundles in the profiler.
- Fix bundles incorrectly marked as released in the Profiler when they are still active
- Improved error message when trying to load a catalog in an unexpected file format.
- Fixed issue where operation that uses WaitForCompletion can timeout much earlier than it should.
- The build scripts were reworked so that you can extend them or copy them outside the package without having to fork the entire package.
- A Version field was added to the Addressables object for getting the package version in the Editor.
- Fixed an issue where tearing down the Addressables instance could happen before user tear down code was getting called.
- Sort collections to make serialized editor files deterministic
- Fixed issue where labels on an addressable sub-entry are incorrectly added to the former parent entry.
- Added support for calling Release() on AsyncOperationHandles directly that couldn't before.
- Fixed sub-object loading from AssetReferences for types that are not Sprites in a SpriteAtlas.


## [2.1.0] - 2024-03-19
- Fix "Unable to verify target bucket for Remote Catalog: Not Found. Object could not be found" error
- Fixed caching to prevent unnecessary refreshing of bucket data.
- Sort collections on serialization to prevent unecessary merge conflicts
- Sort collections on serialization to prevent unnecessary merge conflicts
- Add warnings and documentation to make it clear you need to release the handle from LoadDependenciesAsync

## [2.0.8] - 2024-01-19
Expand Down Expand Up @@ -63,6 +77,8 @@ CCD Manager is built when using the Build to CCD and the standard Build content
- Fixed an issue where "Failed to remove scene from Addressables profiler" warning occurs when a scene is unloaded.
- Fixed an exception getting thrown in the Addressables Report when drilling into a bundle chain
- Fixed string deduplication in binary catalogs. Certain data sets were causing data to expand.
- Removed the Analyze Rule API and corresponding tool
- Removed the Event Viewer API and corresponding tool

## [1.21.18] - 2023-09-23
- Fixed an issue where scene InternalId collisions were very likely when using dynamic internal asset naming
Expand Down
2 changes: 2 additions & 0 deletions Documentation~/DownloadDependenciesAsync.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Always release the download operation handle after you have read the `Result` ob

[!code-cs[sample](../Tests/Editor/DocExampleCode/Preload.cs#doc_Preload)]

To note: On the WebGL platform, this API always returns the size of the AssetBundle, even if the AssetBundle has been cached. Cached AssetBundles are not stored on the local file system, but persisted as part of the IndexedDB of the browser. [WebGL Caching](https://docs.unity3d.com/Manual/webgl-caching.html)

### Clear the dependency cache

If you want to clear any AssetBundles cached by Addressables, call [`Addressables.ClearDependencyCacheAsync`](xref:UnityEngine.AddressableAssets.Addressables.ClearDependencyCacheAsync*). This method clears the cached AssetBundles containing the assets identified by a key along with any bundles containing those assets' dependencies.
Expand Down
2 changes: 1 addition & 1 deletion Editor/Build/AddressableAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ internal static BuildData GenerateBuildData(AddressablesDataBuilderInput builder
if (selected == -1)
pathType = PathType.Custom;
else
pathType = prefixToTypeMap[groupTypes[selected].GroupTypePrefix];
pathType = prefixToTypeMap.GetValueOrDefault(groupTypes[selected].GroupTypePrefix, PathType.Custom);

if (pathType == PathType.Custom)
{
Expand Down
6 changes: 4 additions & 2 deletions Editor/Build/AddressablesDataBuilderInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public class AddressablesDataBuilderInput
/// </summary>
public FileRegistry Registry { get; private set; }

//used only by tests to inject custom info into build...
internal string PathSuffix = string.Empty;
/// <summary>
/// can be used in testing to append a suffix to file paths
/// </summary>
public string PathSuffix = string.Empty;

/// <summary>
/// The name of the default Runtime Settings file.
Expand Down
2 changes: 1 addition & 1 deletion Editor/Build/AddressablesDataBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class BundleBuildResult
/// <summary>
/// True if the build was doing an update to a previous build, else false.
/// </summary>
public bool IsUpdateContentBuild { get; internal set; }
public bool IsUpdateContentBuild { get; set; }

/// <summary>
/// Build results for AssetBundles created during the build.
Expand Down
28 changes: 15 additions & 13 deletions Editor/Build/BuildPipelineTasks/BuildLayoutGenerationTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ public int Version
}

/// <summary>
/// The mapping of the old to new bundle names.
/// The mapping of the old to new bundle names. Instead of using this directly inject
/// the value through IBuildLayoutParUse BuildLayoutParameters.BundleNameRemap instead
/// </summary>
public Dictionary<string, string> BundleNameRemap
{
get { return m_BundleNameRemap; }
set { m_BundleNameRemap = value; }
get { return m_BuildLayoutParameters.BundleNameRemap; }
set { m_BuildLayoutParameters.BundleNameRemap = value; }
}

#pragma warning disable 649
Expand All @@ -70,11 +71,12 @@ public int Version

[InjectContext(ContextUsage.In)]
IBundleBuildResults m_BuildBundleResults;

[InjectContext(ContextUsage.In)]
IBuildLayoutParameters m_BuildLayoutParameters;
#pragma warning restore 649

internal Dictionary<string, string> m_BundleNameRemap;
internal AddressablesDataBuilderInput m_AddressablesInput;
internal ContentCatalogData m_ContentCatalogData;

private bool IsContentUpdateBuild => m_AddressablesInput != null && m_AddressablesInput.PreviousContentState != null;

Expand Down Expand Up @@ -693,14 +695,14 @@ private BuildLayout GenerateBuildLayout(AddressableAssetsBuildContext aaContext,
layout.RemoteCatalogBuildPath = aaContext.Settings.RemoteCatalogBuildPath.GetValue(aaContext.Settings);

AddressableAssetSettings aaSettings = aaContext.Settings;
if (m_ContentCatalogData != null)
layout.BuildResultHash = m_ContentCatalogData.m_BuildResultHash;
if (m_BuildLayoutParameters.BuildResultHash != null)
layout.BuildResultHash = m_BuildLayoutParameters.BuildResultHash;

using (m_Log.ScopedStep(LogLevel.Info, "Generate Basic Information"))
{
SetLayoutMetaData(layout, aaSettings);
layout.AddressablesEditorSettings = GetAddressableEditorSettings(aaSettings);
layout.AddressablesRuntimeSettings = GetAddressableRuntimeSettings(aaContext, m_ContentCatalogData);
layout.AddressablesRuntimeSettings = GetAddressableRuntimeSettings(aaContext);
}

if (IsContentUpdateBuild)
Expand Down Expand Up @@ -847,7 +849,7 @@ void CorrelateBundleToAssetGroup(BuildLayout layout, BuildLayout.Bundle b, Layou
if (aaContext.bundleToAssetGroup.TryGetValue(b.Name, out var grpName))
{
var assetGroup = lookup.GroupLookup[grpName];
b.Name = m_BundleNameRemap[b.Name];
b.Name = m_BuildLayoutParameters.BundleNameRemap[b.Name];
b.Group = assetGroup;
lookup.FilenameToBundle[b.Name] = b;
var filePath = Path.Combine(lookup.GroupNameToBuildPath[assetGroup.Name], b.Name);
Expand All @@ -862,7 +864,7 @@ void CorrelateBundleToAssetGroup(BuildLayout layout, BuildLayout.Bundle b, Layou
{
// bundleToAssetGroup doesn't contain the builtin bundles. The builtin content is built using values from the default group
AddressableAssetGroup defaultGroup = aaContext.Settings.DefaultGroup;
b.Name = m_BundleNameRemap[b.Name];
b.Name = m_BuildLayoutParameters.BundleNameRemap[b.Name];
b.Group = lookup.GroupLookup[defaultGroup.Guid]; // should this be set?
lookup.FilenameToBundle[b.Name] = b;

Expand Down Expand Up @@ -1161,7 +1163,7 @@ private static void SetLayoutMetaData(BuildLayout layoutOut, AddressableAssetSet
layoutOut.PlayerBuildVersion = aaSettings.PlayerBuildVersion;
}

static BuildLayout.AddressablesRuntimeData GetAddressableRuntimeSettings(AddressableAssetsBuildContext aaContext, ContentCatalogData contentCatalog)
BuildLayout.AddressablesRuntimeData GetAddressableRuntimeSettings(AddressableAssetsBuildContext aaContext)
{
if (aaContext.runtimeData == null)
{
Expand All @@ -1175,8 +1177,8 @@ static BuildLayout.AddressablesRuntimeData GetAddressableRuntimeSettings(Address
runtimeSettings.CatalogLoadPaths = new List<string>();
foreach (ResourceLocationData catalogLocation in aaContext.runtimeData.CatalogLocations)
runtimeSettings.CatalogLoadPaths.Add(catalogLocation.InternalId);
if (contentCatalog != null)
runtimeSettings.CatalogHash = contentCatalog.localHash;
if (m_BuildLayoutParameters.CatalogHash != null)
runtimeSettings.CatalogHash = m_BuildLayoutParameters.CatalogHash;

return runtimeSettings;
}
Expand Down
10 changes: 8 additions & 2 deletions Editor/Build/ContentUpdateScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ static bool HasAssetOrDependencyChanged(CachedAssetState cachedInfo)
/// <param name="remoteCatalogPath">The server path (if any) that contains an updateable content catalog. If this is empty, updates cannot occur.</param>
/// <param name="carryOverCacheState">Cached state that needs to carry over from the previous build. This mainly affects Content Update.</param>
/// <returns>True if the file is saved, false otherwise.</returns>
internal static bool SaveContentState(List<ContentCatalogDataEntry> locations, Dictionary<GUID, List<ContentCatalogDataEntry>> guidToCatalogLocation, string path, List<AddressableAssetEntry> entries, IDependencyData dependencyData, string playerVersion,
public static bool SaveContentState(List<ContentCatalogDataEntry> locations, Dictionary<GUID, List<ContentCatalogDataEntry>> guidToCatalogLocation, string path, List<AddressableAssetEntry> entries, IDependencyData dependencyData, string playerVersion,
string remoteCatalogPath, List<CachedAssetState> carryOverCacheState)
{
try
Expand Down Expand Up @@ -477,7 +477,13 @@ public static string GetContentStateDataPath(bool browse)
return GetContentStateDataPath(browse, null);
}

internal static string GetContentStateDataPath(bool browse, AddressableAssetSettings settings)
/// <summary>
/// Gets the path of the cache data from a selected build.
/// </summary>
/// <param name="browse">If true, the user is allowed to browse for a specific file.</param>
/// <param name="settings">The settings object to use for the build.</param>
/// <returns>The path of the previous state .bin file used to detect changes from the previous build to the content update build.</returns>
public static string GetContentStateDataPath(bool browse, AddressableAssetSettings settings)
{
if (settings == null)
settings = AddressableAssetSettingsDefaultObject.Settings;
Expand Down
64 changes: 1 addition & 63 deletions Editor/Build/DataBuilders/AddressableAssetsBuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,68 +94,6 @@ public AddressableAssetSettings Settings
/// <summary>
/// A mapping of Asset GUID's to resulting ContentCatalogDataEntry entries.
/// </summary>
internal Dictionary<GUID, List<ContentCatalogDataEntry>> GuidToCatalogLocation = null;

private Dictionary<string, List<ContentCatalogDataEntry>> m_PrimaryKeyToDependers = null;

internal Dictionary<string, List<ContentCatalogDataEntry>> PrimaryKeyToDependerLocations
{
get
{
if (m_PrimaryKeyToDependers != null)
return m_PrimaryKeyToDependers;
if (locations == null || locations.Count == 0)
{
Debug.LogError("Attempting to get Entries dependent on key, but currently no locations");
return new Dictionary<string, List<ContentCatalogDataEntry>>(0);
}

m_PrimaryKeyToDependers = new Dictionary<string, List<ContentCatalogDataEntry>>(locations.Count);
foreach (ContentCatalogDataEntry location in locations)
{
for (int i = 0; i < location.Dependencies.Count; ++i)
{
string dependencyKey = location.Dependencies[i] as string;
if (string.IsNullOrEmpty(dependencyKey))
continue;

if (!m_PrimaryKeyToDependers.TryGetValue(dependencyKey, out var dependers))
{
dependers = new List<ContentCatalogDataEntry>();
m_PrimaryKeyToDependers.Add(dependencyKey, dependers);
}

dependers.Add(location);
}
}

return m_PrimaryKeyToDependers;
}
}

private Dictionary<string, ContentCatalogDataEntry> m_PrimaryKeyToLocation = null;

internal Dictionary<string, ContentCatalogDataEntry> PrimaryKeyToLocation
{
get
{
if (m_PrimaryKeyToLocation != null)
return m_PrimaryKeyToLocation;
if (locations == null || locations.Count == 0)
{
Debug.LogError("Attempting to get Primary key to entries dependent on key, but currently no locations");
return new Dictionary<string, ContentCatalogDataEntry>();
}

m_PrimaryKeyToLocation = new Dictionary<string, ContentCatalogDataEntry>();
foreach (var loc in locations)
{
if (loc != null && loc.Keys[0] != null && loc.Keys[0] is string && !m_PrimaryKeyToLocation.ContainsKey((string)loc.Keys[0]))
m_PrimaryKeyToLocation[(string)loc.Keys[0]] = loc;
}

return m_PrimaryKeyToLocation;
}
}
public Dictionary<GUID, List<ContentCatalogDataEntry>> GuidToCatalogLocation = null;
}
}
47 changes: 47 additions & 0 deletions Editor/Build/DataBuilders/BuildLayoutParameters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections.Generic;
using UnityEditor.Build.Pipeline.Interfaces;
using UnityEngine.AddressableAssets.ResourceLocators;

namespace UnityEditor.AddressableAssets.Build.DataBuilders
{
public interface IBuildLayoutParameters : IContextObject
{
Dictionary<string, string> BundleNameRemap { get; set; }

string BuildResultHash { get; }

string CatalogHash { get; }
}

public class BuildLayoutParameters : IBuildLayoutParameters
{
private Dictionary<string, string> m_BundleNameRemap;
private ContentCatalogData m_contentCatalogData;

public BuildLayoutParameters(Dictionary<string, string> bundleNameRemap)
{
m_BundleNameRemap = bundleNameRemap;
}

public BuildLayoutParameters(Dictionary<string, string> bundleNameRemap, ContentCatalogData contentCatalogData)
{
m_BundleNameRemap = bundleNameRemap;
m_contentCatalogData = contentCatalogData;
}
public Dictionary<string, string> BundleNameRemap
{
get => m_BundleNameRemap;
set => m_BundleNameRemap = value;
}

public string BuildResultHash
{
get => m_contentCatalogData?.BuildResultHash;
}

public string CatalogHash
{
get => m_contentCatalogData?.LocalHash;
}
}
}
3 changes: 3 additions & 0 deletions Editor/Build/DataBuilders/BuildLayoutParameters.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 580b2db

Please sign in to comment.