Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.16.16] - 2021-01-20
- Updated dependency versions for testcase fix
  • Loading branch information
Unity Technologies committed Jan 20, 2021
1 parent c42adf1 commit b8ec726
Show file tree
Hide file tree
Showing 19 changed files with 979 additions and 499 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ 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.16.16] - 2021-01-20
- Updated dependency versions for testcase fix

## [1.16.15] - 2020-12-09
- Addressables link.xml should now have it's own folder.
- Fixed an issue where InvalidKeyException was getting thrown when calling GetDownloadSizeAsync on scenes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ internal static Output RunInternal(Input input)
throw new Exception($"Address '{entry.address}' cannot contain '[ ]'.");
if (entry.MainAssetType == typeof(DefaultAsset) && !AssetDatabase.IsValidFolder(entry.AssetPath))
{
if (ProjectConfigData.ignoreUnsupportedFilesInBuild)
if (input.Settings.IgnoreUnsupportedFilesInBuild)
Debug.LogWarning($"Cannot recognize file type for entry located at '{entry.AssetPath}'. Asset location will be ignored.");
else
throw new Exception($"Cannot recognize file type for entry located at '{entry.AssetPath}'. Asset import failed for using an unsupported file type.");
Expand Down
17 changes: 14 additions & 3 deletions Editor/Build/ContentUpdateScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ public static bool SaveContentState(string path, List<AddressableAssetEntry> ent
stream.Close();
stream.Dispose();
return true;
}
catch(UnauthorizedAccessException uae)
}
catch (UnauthorizedAccessException uae)
{
if (AddressableAssetUtility.IsUsingVCIntegration())
Debug.LogErrorFormat("Cannot access the file {0}. This may be due to a version control lock.", path);
Expand Down Expand Up @@ -379,7 +379,7 @@ public static bool SaveContentState(List<ContentCatalogDataEntry> locations, str
stream.Dispose();
return true;
}
catch(UnauthorizedAccessException uae)
catch (UnauthorizedAccessException uae)
{
if (AddressableAssetUtility.IsUsingVCIntegration())
Debug.LogErrorFormat("Cannot access the file {0}. Is it checked out?", path);
Expand Down Expand Up @@ -760,5 +760,16 @@ public static void CreateContentUpdateGroup(AddressableAssetSettings settings, L
contentGroup.AddSchema<ContentUpdateGroupSchema>().StaticContent = false;
settings.MoveEntries(items, contentGroup);
}

internal static bool GroupFilter(AddressableAssetGroup g)
{
if (g == null)
return false;
if (!g.HasSchema<ContentUpdateGroupSchema>() || !g.GetSchema<ContentUpdateGroupSchema>().StaticContent)
return false;
if (!g.HasSchema<BundledAssetGroupSchema>() || !g.GetSchema<BundledAssetGroupSchema>().IncludeInBuild)
return false;
return true;
}
}
}
72 changes: 56 additions & 16 deletions Editor/Build/DataBuilders/BuildScriptPackedMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public void Dispose()
var groups = aaContext.Settings.groups.Where(g => g != null);

var bundleRenameMap = new Dictionary<string, string>();
var postCatalogUpdateCallbacks = new List<Action>();
using (m_Log.ScopedStep(LogLevel.Info, "PostProcessBundles"))
using (var progressTracker = new UnityEditor.Build.Pipeline.Utilities.ProgressTracker())
{
Expand All @@ -205,7 +206,7 @@ public void Dispose()
outputBundles.Add(b >= 0 ? m_OutputAssetBundleNames[b] : buildBundles[i]);
}

PostProcessBundles(assetGroup, buildBundles, outputBundles, results, aaContext.runtimeData, aaContext.locations, builderInput.Registry, primaryKeyToCatalogEntry, bundleRenameMap);
PostProcessBundles(assetGroup, buildBundles, outputBundles, results, aaContext.runtimeData, aaContext.locations, builderInput.Registry, primaryKeyToCatalogEntry, bundleRenameMap, postCatalogUpdateCallbacks);
}
}
}
Expand All @@ -222,6 +223,8 @@ public void Dispose()
}

ProcessCatalogEntriesForBuild(aaContext, m_Log, groups, builderInput, extractData.WriteData, carryOverCachedState, m_BundleToInternalId);
foreach (var postUpdateCatalogCallback in postCatalogUpdateCallbacks)
postUpdateCatalogCallback.Invoke();

foreach (var r in results.WriteResults)
{
Expand Down Expand Up @@ -282,7 +285,7 @@ public void Dispose()
if (extractData.BuildCache != null && builderInput.PreviousContentState == null)
{
var allEntries = new List<AddressableAssetEntry>();
aaContext.Settings.GetAllAssets(allEntries, false, FilterGroupForContentState);
aaContext.Settings.GetAllAssets(allEntries, false, ContentUpdateScript.GroupFilter);
var remoteCatalogLoadPath = aaContext.Settings.BuildRemoteCatalog ? aaContext.Settings.RemoteCatalogLoadPath.GetValue(aaContext.Settings) : string.Empty;
if (ContentUpdateScript.SaveContentState(aaContext.locations, tempPath, allEntries, extractData.DependencyData, playerBuildVersion, remoteCatalogLoadPath, carryOverCachedState))
{
Expand All @@ -302,17 +305,6 @@ public void Dispose()
return opResult;
}

private static bool FilterGroupForContentState(AddressableAssetGroup g)
{
if (g == null)
return false;
if (!g.HasSchema<ContentUpdateGroupSchema>() || !g.GetSchema<ContentUpdateGroupSchema>().StaticContent)
return false;
if (!g.HasSchema<BundledAssetGroupSchema>() || !g.GetSchema<BundledAssetGroupSchema>().IncludeInBuild)
return false;
return true;
}

private static void ProcessCatalogEntriesForBuild(AddressableAssetsBuildContext aaContext, IBuildLogger log,
IEnumerable<AddressableAssetGroup> validGroups, AddressablesDataBuilderInput builderInput, IBundleWriteData writeData,
List<CachedAssetState> carryOverCachedState, Dictionary<string, string> bundleToInternalId)
Expand Down Expand Up @@ -493,12 +485,27 @@ internal ReturnCode CreateCatalogBundle(string filepath, string jsonText, Addres
string fullBundleName = writeData.FileToBundle[file];
string convertedLocation = bundleNameToInternalBundleIdMap[fullBundleName];

if (locationIdToCatalogEntryMap.TryGetValue(convertedLocation, out ContentCatalogDataEntry catalogEntry))
if (locationIdToCatalogEntryMap.TryGetValue(convertedLocation,
out ContentCatalogDataEntry catalogEntry))
{
loc.BundleFileId = catalogEntry.InternalId;

//This is where we strip out the temporary hash added to the bundle name for Content Update for the AssetEntry
if(loc.parentGroup?.GetSchema<BundledAssetGroupSchema>()?.BundleNaming ==
BundledAssetGroupSchema.BundleNamingStyle.NoHash)
{
loc.BundleFileId = StripHashFromBundleLocation(loc.BundleFileId);
}
}
}
}
}

static string StripHashFromBundleLocation(string hashedBundleLocation)
{
return hashedBundleLocation.Remove(hashedBundleLocation.LastIndexOf("_")) + ".bundle";
}

/// <inheritdoc />
protected override string ProcessGroup(AddressableAssetGroup assetGroup, AddressableAssetsBuildContext aaContext)
{
Expand Down Expand Up @@ -860,7 +867,7 @@ static void CopyFileWithTimestampIfDifferent(string srcPath, string destPath, IB
}
}

void PostProcessBundles(AddressableAssetGroup assetGroup, List<string> buildBundles, List<string> outputBundles, IBundleBuildResults buildResult, ResourceManagerRuntimeData runtimeData, List<ContentCatalogDataEntry> locations, FileRegistry registry, Dictionary<string, ContentCatalogDataEntry> primaryKeyToCatalogEntry, Dictionary<string, string> bundleRenameMap)
void PostProcessBundles(AddressableAssetGroup assetGroup, List<string> buildBundles, List<string> outputBundles, IBundleBuildResults buildResult, ResourceManagerRuntimeData runtimeData, List<ContentCatalogDataEntry> locations, FileRegistry registry, Dictionary<string, ContentCatalogDataEntry> primaryKeyToCatalogEntry, Dictionary<string, string> bundleRenameMap, List<Action> postCatalogUpdateCallbacks)
{
var schema = assetGroup.GetSchema<BundledAssetGroupSchema>();
if (schema == null)
Expand Down Expand Up @@ -916,10 +923,35 @@ void PostProcessBundles(AddressableAssetGroup assetGroup, List<string> buildBund
bundleRenameMap.Add(buildBundles[i], outputBundles[i]);
CopyFileWithTimestampIfDifferent(srcPath, targetPath, m_Log);

AddPostCatalogUpdatesInternal(assetGroup, postCatalogUpdateCallbacks, dataEntry, targetPath);

registry.AddFile(targetPath);
}
}

internal void AddPostCatalogUpdatesInternal(AddressableAssetGroup assetGroup, List<Action> postCatalogUpdates, ContentCatalogDataEntry dataEntry, string targetBundlePath)
{
if (assetGroup.GetSchema<BundledAssetGroupSchema>()?.BundleNaming ==
BundledAssetGroupSchema.BundleNamingStyle.NoHash)
{
postCatalogUpdates.Add(() =>
{
//This is where we strip out the temporary hash for the final bundle location and filename
string bundleNameWithoutHash = StripHashFromBundleLocation(targetBundlePath);
if (File.Exists(targetBundlePath))
{
if (File.Exists(bundleNameWithoutHash))
File.Delete(bundleNameWithoutHash);
File.Move(targetBundlePath, bundleNameWithoutHash);
}
if (dataEntry != null)
dataEntry.InternalId = bundleNameWithoutHash;
});
}
}

/// <summary>
/// Creates a name for an asset bundle using the provided information.
/// </summary>
Expand All @@ -932,7 +964,15 @@ protected virtual string ConstructAssetBundleName(AddressableAssetGroup assetGro
{
string groupName = assetGroup.Name.Replace(" ", "").Replace('\\', '/').Replace("//", "/").ToLower();
assetBundleName = groupName + "_" + assetBundleName;
return BuildUtility.GetNameWithHashNaming(schema.BundleNaming, info.Hash.ToString(), assetBundleName);
string bundleNameWithHashing = BuildUtility.GetNameWithHashNaming(schema.BundleNaming, info.Hash.ToString(), assetBundleName);
//For no hash, we need the hash temporarily for content update purposes. This will be stripped later on.
if (assetGroup.GetSchema<BundledAssetGroupSchema>()?.BundleNaming ==
BundledAssetGroupSchema.BundleNamingStyle.NoHash)
{
bundleNameWithHashing = bundleNameWithHashing.Replace(".bundle", "_" + info.Hash.ToString() + ".bundle");
}

return bundleNameWithHashing;
}

static void ReplaceDependencyKeys(string from, string to, List<ContentCatalogDataEntry> locations)
Expand Down
5 changes: 4 additions & 1 deletion Editor/GUI/AddressableAssetSettingsInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ public override void OnInspectorGUI()
m_QueuedChanges.Add(() => m_AasTarget.MaxConcurrentWebRequests = maxWebReqs);

ProjectConfigData.showGroupsAsHierarchy = EditorGUILayout.Toggle(m_groupHierarchyView, ProjectConfigData.showGroupsAsHierarchy);
ProjectConfigData.ignoreUnsupportedFilesInBuild = EditorGUILayout.Toggle(m_IgnoreUnsupportedFilesInBuild, ProjectConfigData.ignoreUnsupportedFilesInBuild);

bool ignoreUnsupportedFilesInBuild = EditorGUILayout.Toggle(m_IgnoreUnsupportedFilesInBuild, m_AasTarget.IgnoreUnsupportedFilesInBuild);
if (ignoreUnsupportedFilesInBuild != m_AasTarget.IgnoreUnsupportedFilesInBuild)
m_QueuedChanges.Add(() => m_AasTarget.IgnoreUnsupportedFilesInBuild = ignoreUnsupportedFilesInBuild);
}

GUILayout.Space(6);
Expand Down
17 changes: 5 additions & 12 deletions Editor/GUI/AddressableAssetsSettingsGroupEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AddressableAssetsSettingsGroupEditor

SearchField m_SearchField;
const int k_SearchHeight = 20;
internal AddressableAssetSettings settings { get { return AddressableAssetSettingsDefaultObject.Settings; } }
internal AddressableAssetSettings settings;

bool m_ResizingVerticalSplitter;
Rect m_VerticalSplitterRect = new Rect(0, 0, 10, k_SplitterWidth);
Expand All @@ -40,6 +40,7 @@ class AddressableAssetsSettingsGroupEditor
public AddressableAssetsSettingsGroupEditor(AddressableAssetsWindow w)
{
window = w;
settings = AddressableAssetSettingsDefaultObject.Settings;
m_VerticalSplitterPercent = 0.8f;
OnEnable();
}
Expand Down Expand Up @@ -226,15 +227,7 @@ void TopToolbar(Rect toolbarPos)
var searchString = m_SearchField.OnGUI(searchRect, baseSearch, m_SearchStyles[0], m_SearchStyles[1], m_SearchStyles[2]);
if (baseSearch != searchString)
{
if (ProjectConfigData.hierarchicalSearch)
{
m_EntryTree.customSearchString = searchString;
Reload();
}
else
{
m_EntryTree.searchString = searchString;
}
m_EntryTree?.Search(searchString);
}
}
}
Expand Down Expand Up @@ -367,8 +360,8 @@ public bool OnGUI(Rect pos)
{
if (settings == null)
return false;
if (!m_ModificationRegistered)

if (!m_ModificationRegistered)
{
m_ModificationRegistered = true;
settings.OnModification -= OnSettingsModification; //just in case...
Expand Down
31 changes: 27 additions & 4 deletions Editor/GUI/AddressableAssetsSettingsGroupTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ enum ColumnId
ColumnId.Path,
ColumnId.Labels
};

internal AddressableAssetEntryTreeView(AddressableAssetSettings settings)
: this(new TreeViewState(), CreateDefaultMultiColumnHeaderState(), new AddressableAssetsSettingsGroupEditor(ScriptableObject.CreateInstance<AddressableAssetsWindow>()))
{
m_Editor.settings = settings;
}

public AddressableAssetEntryTreeView(TreeViewState state, MultiColumnHeaderState mchs, AddressableAssetsSettingsGroupEditor ed) : base(state, new MultiColumnHeader(mchs))
{
showBorder = true;
Expand All @@ -45,6 +52,8 @@ public AddressableAssetEntryTreeView(TreeViewState state, MultiColumnHeaderState
BuiltinSceneCache.sceneListChanged += OnScenesChanged;
}

internal TreeViewItem Root => rootItem;

void OnScenesChanged()
{
Reload();
Expand Down Expand Up @@ -125,6 +134,21 @@ protected override IList<TreeViewItem> BuildRows(TreeViewItem root)
return base.BuildRows(root);
}

internal IList<TreeViewItem> Search(string search)
{
if (ProjectConfigData.hierarchicalSearch)
{
customSearchString = search;
Reload();
}
else
{
searchString = search;
}

return GetRows();
}

protected IList<TreeViewItem> Search(IList<TreeViewItem> rows)
{
if (rows == null)
Expand Down Expand Up @@ -311,7 +335,7 @@ void AddGroupChildrenBuild(AddressableAssetGroup group, TreeViewItem root)
TreeViewItem newRoot = root;
var parts = group.Name.Split('-');
string partialRestore = "";
for(int index = 0; index < parts.Length-1; index++)
for (int index = 0; index < parts.Length - 1; index++)
{
TreeViewItem folderItem = null;
partialRestore += parts[index];
Expand All @@ -324,7 +348,7 @@ void AddGroupChildrenBuild(AddressableAssetGroup group, TreeViewItem root)
depth++;
newRoot = folderItem;
}

groupItem = new AssetEntryTreeViewItem(group, depth);
newRoot.AddChild(groupItem);
}
Expand All @@ -338,7 +362,7 @@ void AddGroupChildrenBuild(AddressableAssetGroup group, TreeViewItem root)
{
foreach (var entry in group.entries)
{
AddAndRecurseEntriesBuild(entry, groupItem, depth+1, IsExpanded(groupItem.id));
AddAndRecurseEntriesBuild(entry, groupItem, depth + 1, IsExpanded(groupItem.id));
}
}
}
Expand Down Expand Up @@ -1416,7 +1440,6 @@ public override string displayName
base.displayName = value;
}
}

}


Expand Down
Loading

0 comments on commit b8ec726

Please sign in to comment.