Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.18.15] - 2021-07-26
- Improved Addressables inspector for Assets.
- Fixed issue where the hosting window would use an exceptionally high (8-20%) amount of CPU while open with a hosting service created
- Added update on profile change, changed to remove preceding slashes and change all to forward slash for hosting service
- Added documentation explaining why we are unable to support WaitForCompletion (sync Addressables) on WebGL
  • Loading branch information
Unity Technologies committed Jul 26, 2021
1 parent 0a1062b commit 8fbbb7a
Show file tree
Hide file tree
Showing 36 changed files with 692 additions and 201 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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.15] - 2021-07-26
- Improved Addressables inspector for Assets.
- Fixed issue where the hosting window would use an exceptionally high (8-20%) amount of CPU while open with a hosting service created
- Added update on profile change, changed to remove preceding slashes and change all to forward slash for hosting service
- Added documentation explaining why we are unable to support WaitForCompletion (sync Addressables) on WebGL

## [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
Expand Down
7 changes: 6 additions & 1 deletion Documentation~/SynchronousAddressables.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ void Start()
### Synchronous Addressables with Custom Operations
Addressables supports custom `AsyncOperations` which support unique implementations of `InvokeWaitForCompletion`. This overridable method is what you'll use to implement custom synchronous operations.

Custom operations work with `ChainOperations` and `GroupsOperations`. If you require chained operations to be completed synchronously, ensure that your custom operations implement `InvokeWaitForCompletion` and create a `ChainOperation` using your custom operations. Similarly, `GroupOperations` are well suited to ensure a collection of `AsyncOperations`, including custom operations, complete together. Both `ChainOperation` and `GroupOperation` have their own implementations of `InvokeWaitForCompletion` that relies on the `InvokeWaitForCompletion` implementations of the operations they depend on.
Custom operations work with `ChainOperations` and `GroupsOperations`. If you require chained operations to be completed synchronously, ensure that your custom operations implement `InvokeWaitForCompletion` and create a `ChainOperation` using your custom operations. Similarly, `GroupOperations` are well suited to ensure a collection of `AsyncOperations`, including custom operations, complete together. Both `ChainOperation` and `GroupOperation` have their own implementations of `InvokeWaitForCompletion` that relies on the `InvokeWaitForCompletion` implementations of the operations they depend on.

### WebGL
WebGL does not support `WaitForCompletion`. On WebGL, all files are loaded using a web request. On other platforms, a web request gets started on a background thread and the main thread spins in a tight loop while waiting for the web request to finish. This is how Addressables does it for `WaitForCompletion` when a web request is used.

Since WebGL is single-threaded, the tight loop blocks the web request and the operation is never allowed to finish. If a web request finishes the same frame it was created, then `WaitForCompletion` wouldn't have any issue. However, we cannot guarantee this to be the case, and likely it isn't the case for most instances.
2 changes: 2 additions & 0 deletions Editor/Build/AddressablesPlayerBuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public int callbackOrder
/// <summary>
/// Restores temporary data created as part of a build.
/// </summary>
/// <param name="report">Stores temporary player build data.</param>
public void OnPostprocessBuild(BuildReport report)
{
CleanTemporaryPlayerBuildData();
Expand All @@ -39,6 +40,7 @@ internal static void CleanTemporaryPlayerBuildData()
///<summary>
/// Initializes temporary build data.
/// </summary>
/// <param name="report">Contains build data information.</param>
public void OnPreprocessBuild(BuildReport report)
{
CopyTemporaryPlayerBuildData();
Expand Down
15 changes: 15 additions & 0 deletions Editor/Build/MonoScriptBundleNaming.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
namespace UnityEditor.AddressableAssets.Build
{
/// <summary>
/// Naming conventions for the monoscript bundle name prefix.
/// </summary>
public enum MonoScriptBundleNaming
{
/// <summary>
/// No special prefix will be added to the monscript bundle name.
/// </summary>
Disabled,
/// <summary>
/// Set the monoscript bundle name prefix to the hash of the project name.
/// </summary>
ProjectName,
/// <summary>
/// Set the monoscript bundle name prefix to the guid of the default group.
/// </summary>
DefaultGroupGuid,
/// <summary>
/// Set the monoscript bundle name prefix to the user specified value.
/// </summary>
Custom
}
}
Expand Down
23 changes: 16 additions & 7 deletions Editor/Build/RevertUnchangedAssetsToPreviousAssetState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.ResourceProviders;
using UnityEngine.ResourceManagement.Util;
using static UnityEditor.AddressableAssets.Build.ContentUpdateScript;

/// <summary>
Expand All @@ -31,7 +32,7 @@ internal struct AssetEntryRevertOperation
}

/// <summary>
/// Reverts asset entries to their previous state if not modified by the new build.
/// Reverts asset entries to their previous state if not modified by the new build.
/// </summary>
/// <param name="aaBuildContext">The new build data.</param>
/// <param name="updateContext">The cached build data.</param>
Expand Down Expand Up @@ -109,8 +110,7 @@ internal static List<AssetEntryRevertOperation> DetermineRequiredAssetEntryUpdat
continue;
}

string previousBundlePath = previousAssetState.bundleFileId?.Replace(loadPath, buildPath);

string previousBundlePath = BundleIdToBuildPath(previousAssetState.bundleFileId, loadPath, buildPath);
if (!File.Exists(previousBundlePath))
{
//Logging this as a warning because users may choose to delete their bundles on disk which will trigger this state.
Expand All @@ -119,7 +119,7 @@ internal static List<AssetEntryRevertOperation> DetermineRequiredAssetEntryUpdat
$"\"Use Existing Build (requires built groups)\" will fail.");
}

string builtBundlePath = contentUpdateContext.BundleToInternalBundleIdMap[fullInternalBundleName].Replace(loadPath, buildPath);
string builtBundlePath = BundleIdToBuildPath(contentUpdateContext.BundleToInternalBundleIdMap[fullInternalBundleName], loadPath, buildPath);

AssetEntryRevertOperation operation = new AssetEntryRevertOperation()
{
Expand All @@ -134,10 +134,19 @@ internal static List<AssetEntryRevertOperation> DetermineRequiredAssetEntryUpdat
}
return operations;
}


internal static string BundleIdToBuildPath(string bundleId, string rootLoadPath, string rootBuildPath)
{
if (bundleId == null)
return null;
bool replaceBackSlashes = rootLoadPath.Contains('/') && !ResourceManagerConfig.ShouldPathUseWebRequest(rootLoadPath);
string path = replaceBackSlashes ? bundleId.Replace('\\', '/') : bundleId;
return path.Replace(rootLoadPath, rootBuildPath);
}

private static bool IsPreviouslyRevertedDependency(string bundleFileId, ContentUpdateContext contentUpdateContext)
{
foreach(CachedAssetState state in contentUpdateContext.PreviousAssetStateCarryOver)
foreach (CachedAssetState state in contentUpdateContext.PreviousAssetStateCarryOver)
{
if (state.bundleFileId == bundleFileId)
return true;
Expand All @@ -155,7 +164,7 @@ internal static void ApplyAssetEntryUpdates(
{
//Check that we can replace the entry in the file registry
//before continuing. Past this point destructive actions are taken.
if (contentUpdateContext.Registry.ReplaceBundleEntry(Path.GetFileNameWithoutExtension(operation.PreviousBuildPath), operation.PreviousAssetState.bundleFileId) ||
if (contentUpdateContext.Registry.ReplaceBundleEntry(Path.GetFileNameWithoutExtension(operation.PreviousBuildPath), operation.PreviousAssetState.bundleFileId) ||
IsPreviouslyRevertedDependency(operation.PreviousAssetState.bundleFileId, contentUpdateContext))
{
File.Delete(operation.CurrentBuildPath);
Expand Down
12 changes: 12 additions & 0 deletions Editor/Build/ShaderBundleNaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@

namespace UnityEditor.AddressableAssets.Build
{
/// <summary>
/// Naming conventions for the built-in shader bundle name prefix.
/// </summary>
public enum ShaderBundleNaming
{
/// <summary>
/// Set the built-in shader bundle name prefix to the hash of the project name.
/// </summary>
ProjectName,
/// <summary>
/// Set the built-in shader bundle name prefix to the guid of the default group.
/// </summary>
DefaultGroupGuid,
/// <summary>
/// Set the built-in shader bundle name prefix to the user specified value.
/// </summary>
Custom
}
}
Expand Down
17 changes: 16 additions & 1 deletion Editor/GUI/AddressableAssetsSettingsGroupEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,22 @@ public void SelectEntries(IList<AddressableAssetEntry> entries)
while (items.Count > 0)
{
var i = items.Pop();
if (!i.IsGroup && entries.Contains(i.entry))

bool contains = false;
if (i.entry != null)
{
foreach (AddressableAssetEntry entry in entries)
{
// class instances can be different but refer to the same entry, use guid
if (entry.guid == i.entry.guid && i.entry.TargetAsset == entry.TargetAsset)
{
contains = true;
break;
}
}
}

if (!i.IsGroup && contains)
{
selectedIDs.Add(i.id);
}
Expand Down
Loading

0 comments on commit 8fbbb7a

Please sign in to comment.