Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.18.13] - 2021-07-13
- Fixed issue where Addressables would not use a custom Asset Bundle Provider if the default group was empty
- InvalidKeyExceptions are now correctly thrown as InvalidKeyExceptions, as opposed to before, where they were thrown as System.Exceptions. Please note that this may break any checks that rely on InvalidKeyExceptions being thrown as System.Exception
- Fixed issue where UnauthorizedAccessException is logged during a build if content_state.bin is locked by version control integration.
- Fixed issue where user defined callbacks can cause unexpected behavior for async operations that are automatically released.
- Fixed issue where Content Update would not include folder entry sub entries.
- Fixed issue where NullReferenceException was logged when multi-selecting with Resource in Groups TreeView.
- Fixed issue where Check for Content Update Restrictions excludes dependencies for folder entries.
- Fixed issue where AddPostCatalogUpdatesInternal would attempt to remove the hash from strings that did not include a hash, occassionally leading to incorrect bundle names in catalog.json
- Load AssetBundles Asynchronously from UnityWebRequest for supported Editor versions
- Fixed issue where hidden files were being flagged in GetDownloadSizeAsync when "Use Asset Database (fastest)" is enabled.
- Added logic for auto releasing completion handle in InitializeAsync
- Fixed issue where AssetBundleProvider would fail to retry on download dailed
- Fixed bug where Fast Mode wasn't returning the correct resource locations or their types, especially for sub-objects.
- Fixed bug where Hosting Service was not saving if enabled between domain reloads
- Fixed bug where Scenes with Group setting Asset Internal Naming Mode of Filename failed to load
- Fixed bug where Hosting window would occassionally be empty on startup.
  • Loading branch information
Unity Technologies committed Jul 13, 2021
1 parent 74ca2a7 commit 0a1062b
Show file tree
Hide file tree
Showing 32 changed files with 650 additions and 150 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +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).

## [1.18.13] - 2021-07-13
- Fixed issue where Addressables would not use a custom Asset Bundle Provider if the default group was empty
- InvalidKeyExceptions are now correctly thrown as InvalidKeyExceptions, as opposed to before, where they were thrown as System.Exceptions. Please note that this may break any checks that rely on InvalidKeyExceptions being thrown as System.Exception
- Fixed issue where UnauthorizedAccessException is logged during a build if content_state.bin is locked by version control integration.
- Fixed issue where user defined callbacks can cause unexpected behavior for async operations that are automatically released.
- Fixed issue where Content Update would not include folder entry sub entries.
- Fixed issue where NullReferenceException was logged when multi-selecting with Resource in Groups TreeView.
- Fixed issue where Check for Content Update Restrictions excludes dependencies for folder entries.
- Fixed issue where AddPostCatalogUpdatesInternal would attempt to remove the hash from strings that did not include a hash, occassionally leading to incorrect bundle names in catalog.json
- Load AssetBundles Asynchronously from UnityWebRequest for supported Editor versions
- Fixed issue where hidden files were being flagged in GetDownloadSizeAsync when "Use Asset Database (fastest)" is enabled.
- Added logic for auto releasing completion handle in InitializeAsync
- Fixed issue where AssetBundleProvider would fail to retry on download dailed
- Fixed bug where Fast Mode wasn't returning the correct resource locations or their types, especially for sub-objects.
- Fixed bug where Hosting Service was not saving if enabled between domain reloads
- Fixed bug where Scenes with Group setting Asset Internal Naming Mode of Filename failed to load
- Fixed bug where Hosting window would occassionally be empty on startup.

## [1.18.11] - 2021-06-15
- Improved performance of Labels popup in Groups Window.
- Added "Copy Address to Clipboard" Context menu option in Groups Window.
Expand Down
49 changes: 28 additions & 21 deletions Editor/Build/AddressableAssetSettingsLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,21 @@ static void GatherEntryLocations(AddressableAssetEntry entry, Type type, IList<I
if(type == null || type == typeof(object) || type == typeof(SceneInstance) || AddressableAssetUtility.MapEditorTypeToRuntimeType(e.MainAssetType, false) == type )
locations.Add(new ResourceLocationBase(e.address, e.AssetPath, typeof(SceneProvider).FullName, typeof(SceneInstance)));
}
else if (type == null || type.IsAssignableFrom(e.MainAssetType))
else if (type == null || (type.IsAssignableFrom(e.MainAssetType) && type != typeof(object)))
{
locations.Add(new ResourceLocationBase(e.address, e.AssetPath, typeof(AssetDatabaseProvider).FullName, e.MainAssetType));
return true;
}
else
{
ObjectIdentifier[] ids = ContentBuildInterface.GetPlayerObjectIdentifiersInAsset(new GUID(e.guid), EditorUserBuildSettings.activeBuildTarget);
if (ids.Length > 1)
if (ids.Length > 0)
{
foreach (var t in AddressableAssetEntry.GatherSubObjectTypes(ids, e.guid))
{
if (type.IsAssignableFrom(t))
locations.Add(new ResourceLocationBase(e.address, e.AssetPath, typeof(AssetDatabaseProvider).FullName, t));
locations.Add(new ResourceLocationBase(e.address, e.AssetPath, typeof(AssetDatabaseProvider).FullName, AddressableAssetUtility.MapEditorTypeToRuntimeType(t, false)));
}

return true;
}
}
Expand Down Expand Up @@ -241,6 +240,9 @@ public bool Locate(object key, Type type, out IList<IResourceLocation> locations
}
}
}

if (type == null)
type = typeof(UnityEngine.Object);

string keyStr = key as string;
if (!string.IsNullOrEmpty(keyStr))
Expand All @@ -262,11 +264,7 @@ public bool Locate(object key, Type type, out IList<IResourceLocation> locations

if (m_keyToEntries.ContainsKey(parentFolderKey))
{
string keyAssetPath = AssetDatabase.GUIDToAssetPath(keyStr);
if (type == m_SpriteType && AssetDatabase.GetMainAssetTypeAtPath(keyAssetPath) == m_SpriteAtlasType)
locations.Add(new ResourceLocationBase(keyPath, keyAssetPath, typeof(AssetDatabaseProvider).FullName, m_SpriteAtlasType));
else
locations.Add(new ResourceLocationBase(keyPath, keyAssetPath, typeof(AssetDatabaseProvider).FullName, type));
AddLocations(locations, type, keyPath, AssetDatabase.GUIDToAssetPath(keyStr));
break;
}
slash = keyPath.LastIndexOf('/');
Expand All @@ -284,16 +282,7 @@ public bool Locate(object key, Type type, out IList<IResourceLocation> locations
if (m_keyToEntries.TryGetValue(keyPath, out var entry))
{
foreach (var e in entry)
{
var internalId = GetInternalIdFromFolderEntry(keyStr, e);
if (!string.IsNullOrEmpty(internalId) && !string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(internalId)))
{
if (type == m_SpriteType && AssetDatabase.GetMainAssetTypeAtPath(internalId) == m_SpriteAtlasType)
locations.Add(new ResourceLocationBase(keyStr, internalId, typeof(AssetDatabaseProvider).FullName, m_SpriteAtlasType));
else
locations.Add(new ResourceLocationBase(keyStr, internalId, typeof(AssetDatabaseProvider).FullName, type));
}
}
AddLocations(locations, type, keyStr, GetInternalIdFromFolderEntry(keyStr, e));
break;
}
slash = keyPath.LastIndexOf('/');
Expand All @@ -304,7 +293,7 @@ public bool Locate(object key, Type type, out IList<IResourceLocation> locations
if (m_includeResourcesFolders)
{
string resPath = keyStr;
UnityEngine.Object obj = Resources.Load(resPath, type == null ? typeof(UnityEngine.Object) : type);
UnityEngine.Object obj = Resources.Load(resPath, type);
if (obj == null && keyStr.Length == 32)
{
resPath = AssetDatabase.GUIDToAssetPath(keyStr);
Expand All @@ -316,7 +305,7 @@ public bool Locate(object key, Type type, out IList<IResourceLocation> locations
int start = index + 10;
int length = resPath.Length - (start + System.IO.Path.GetExtension(resPath).Length);
resPath = resPath.Substring(index + 10, length);
obj = Resources.Load(resPath, type == null ? typeof(UnityEngine.Object) : type);
obj = Resources.Load(resPath, type);
}
}
}
Expand All @@ -335,6 +324,24 @@ public bool Locate(object key, Type type, out IList<IResourceLocation> locations
m_Cache.Add(cacheKey, locations);
return true;
}

internal static void AddLocations(IList<IResourceLocation> locations, Type type, string keyStr, string internalId)
{
if (!string.IsNullOrEmpty(internalId) && !string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(internalId)))
{
if (type == m_SpriteType && AssetDatabase.GetMainAssetTypeAtPath(internalId) == m_SpriteAtlasType)
locations.Add(new ResourceLocationBase(keyStr, internalId, typeof(AssetDatabaseProvider).FullName, m_SpriteAtlasType));
else
{
foreach (var obj in AssetDatabaseProvider.LoadAssetsWithSubAssets(internalId))
{
var rtt = AddressableAssetUtility.MapEditorTypeToRuntimeType(obj.GetType(), false);
if (type.IsAssignableFrom(rtt))
locations.Add(new ResourceLocationBase(keyStr, internalId, typeof(AssetDatabaseProvider).FullName, rtt));
}
}
}
}

string GetInternalIdFromFolderEntry(string keyStr, AddressableAssetEntry entry)
{
Expand Down
51 changes: 27 additions & 24 deletions Editor/Build/ContentUpdateScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,40 +153,40 @@ public class AddressablesContentState
public static class ContentUpdateScript
{
/// <summary>
/// Contains build information used for updating assets.
/// Contains build information used for updating assets.
/// </summary>
public struct ContentUpdateContext
{
/// <summary>
/// The mapping of an asset's guid to its cached asset state.
/// </summary>
public Dictionary<string, CachedAssetState> GuidToPreviousAssetStateMap;

/// <summary>
/// The mapping of an asset's or bundle's internal id to its catalog entry.
/// </summary>
public Dictionary<string, ContentCatalogDataEntry> IdToCatalogDataEntryMap;

/// <summary>
/// The mapping of a bundle's name to its internal bundle id.
/// </summary>
public Dictionary<string, string> BundleToInternalBundleIdMap;

/// <summary>
/// Stores the asset bundle write information.
/// </summary>
public IBundleWriteData WriteData;

/// <summary>
/// Stores the cached build data.
/// </summary>
public AddressablesContentState ContentState;

/// <summary>
/// Stores the paths of the files created during a build.
/// </summary>
public FileRegistry Registry;

/// <summary>
/// The list of asset state information gathered from the previous build.
/// </summary>
Expand Down Expand Up @@ -336,7 +336,7 @@ public static bool SaveContentState(List<ContentCatalogDataEntry> locations, str
catch (UnauthorizedAccessException uae)
{
if (!AddressableAssetUtility.IsVCAssetOpenForEdit(path))
Debug.LogErrorFormat("Cannot access the file {0}. Is it checked out?", path);
Debug.LogErrorFormat("Cannot access the file {0}. It may be locked by version control.", path);
else
Debug.LogException(uae);
return false;
Expand Down Expand Up @@ -381,7 +381,7 @@ static IList<CachedAssetState> GetCachedAssetStates(List<ContentCatalogDataEntry

return cachedInfos;
}

/// <summary>
/// Gets the path of the cache data from a selected build.
/// </summary>
Expand All @@ -392,7 +392,7 @@ public static string GetContentStateDataPath(bool browse)
string assetPath = AddressableAssetSettingsDefaultObject.Settings != null ?
AddressableAssetSettingsDefaultObject.Settings.GetContentStateBuildPath() :
Path.Combine(AddressableAssetSettingsDefaultObject.kDefaultConfigFolder, PlatformMappingService.GetPlatformPathSubFolder());

if (browse)
{
if (string.IsNullOrEmpty(assetPath))
Expand Down Expand Up @@ -422,7 +422,7 @@ public static string GetContentStateDataPath(bool browse)
}
else
Directory.CreateDirectory(assetPath);

var path = Path.Combine(assetPath, "addressables_content_state.bin");
return path;
}
Expand Down Expand Up @@ -619,9 +619,9 @@ public static Dictionary<AddressableAssetEntry, List<AddressableAssetEntry>> Gat
AddressablesContentState cacheData = LoadContentState(cachePath);
if (cacheData == null)
return modifiedData;

GatherExplicitModifiedEntries(settings, ref modifiedData, cacheData);
GetStaticContentDependenciesForEntries(settings, ref modifiedData, cacheData);
GetStaticContentDependenciesForEntries(settings, ref modifiedData, GetGroupGuidToCacheBundleNameMap(cacheData));
return modifiedData;
}

Expand All @@ -637,19 +637,23 @@ internal static Dictionary<string, string> GetGroupGuidToCacheBundleNameMap(Addr
var groupGuidToCacheBundleName = new Dictionary<string, string>();
foreach (CachedAssetState cacheInfo in cacheData.cachedInfos)
{
if(cacheInfo != null && bundleIdToCacheInfo.TryGetValue(cacheInfo.bundleFileId, out string bundleName))
if (cacheInfo != null && bundleIdToCacheInfo.TryGetValue(cacheInfo.bundleFileId, out string bundleName))
groupGuidToCacheBundleName[cacheInfo.groupGuid] = bundleName;
}
return groupGuidToCacheBundleName;
}

internal static HashSet<string> GetGroupGuidsWithUnchangedBundleName(AddressableAssetSettings settings, Dictionary<AddressableAssetEntry, List<AddressableAssetEntry>> dependencyMap, AddressablesContentState cacheData)
internal static HashSet<string> GetGroupGuidsWithUnchangedBundleName(AddressableAssetSettings settings, Dictionary<AddressableAssetEntry, List<AddressableAssetEntry>> dependencyMap, Dictionary<string, string> groupGuidToCacheBundleName)
{
var result = new HashSet<string>();
if (cacheData == null)
if (groupGuidToCacheBundleName == null || groupGuidToCacheBundleName.Count == 0)
return result;

Dictionary<string, string> groupGuidToCacheBundleName = GetGroupGuidToCacheBundleNameMap(cacheData);
var entryGuidToDeps = new Dictionary<string, List<AddressableAssetEntry>>();
foreach (KeyValuePair<AddressableAssetEntry, List<AddressableAssetEntry>> entryToDeps in dependencyMap)
{
entryGuidToDeps.Add(entryToDeps.Key.guid, entryToDeps.Value);
}

foreach (AddressableAssetGroup group in settings.groups)
{
Expand All @@ -659,7 +663,7 @@ internal static HashSet<string> GetGroupGuidsWithUnchangedBundleName(Addressable
var schema = group.GetSchema<BundledAssetGroupSchema>();
List<AssetBundleBuild> bundleInputDefinitions = new List<AssetBundleBuild>();

BuildScriptPackedMode.PrepGroupBundlePacking(group, bundleInputDefinitions, schema, x => !dependencyMap.ContainsKey(x));
BuildScriptPackedMode.PrepGroupBundlePacking(group, bundleInputDefinitions, schema, entry => !entryGuidToDeps.ContainsKey(entry.guid));
BuildScriptPackedMode.HandleDuplicateBundleNames(bundleInputDefinitions);

for (int i = 0; i < bundleInputDefinitions.Count; i++)
Expand All @@ -672,14 +676,13 @@ internal static HashSet<string> GetGroupGuidsWithUnchangedBundleName(Addressable
return result;
}

internal static void GetStaticContentDependenciesForEntries(AddressableAssetSettings settings, ref Dictionary<AddressableAssetEntry, List<AddressableAssetEntry>> dependencyMap, AddressablesContentState cacheData = null)
internal static void GetStaticContentDependenciesForEntries(AddressableAssetSettings settings, ref Dictionary<AddressableAssetEntry, List<AddressableAssetEntry>> dependencyMap, Dictionary<string, string> groupGuidToCacheBundleName = null)
{
Dictionary<AddressableAssetGroup, bool> groupHasStaticContentMap = new Dictionary<AddressableAssetGroup, bool>();

if (dependencyMap == null)
return;

HashSet<string> groupGuidsWithUnchangedBundleName = GetGroupGuidsWithUnchangedBundleName(settings, dependencyMap, cacheData);
Dictionary<AddressableAssetGroup, bool> groupHasStaticContentMap = new Dictionary<AddressableAssetGroup, bool>();
HashSet<string> groupGuidsWithUnchangedBundleName = GetGroupGuidsWithUnchangedBundleName(settings, dependencyMap, groupGuidToCacheBundleName);

foreach (AddressableAssetEntry entry in dependencyMap.Keys)
{
Expand All @@ -692,15 +695,15 @@ internal static void GetStaticContentDependenciesForEntries(AddressableAssetSett
foreach (string dependency in dependencies)
{
string guid = AssetDatabase.AssetPathToGUID(dependency);
var depEntry = settings.FindAssetEntry(guid);
var depEntry = settings.FindAssetEntry(guid, true);
if (depEntry == null)
continue;

if (!groupHasStaticContentMap.TryGetValue(depEntry.parentGroup, out bool groupHasStaticContentEnabled))
{
groupHasStaticContentEnabled = depEntry.parentGroup.HasSchema<ContentUpdateGroupSchema>() &&
depEntry.parentGroup.GetSchema<ContentUpdateGroupSchema>().StaticContent;

if (groupGuidsWithUnchangedBundleName.Contains(depEntry.parentGroup.Guid))
continue;

Expand Down
Loading

0 comments on commit 0a1062b

Please sign in to comment.