Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.18.4] - 2021-05-06
- EditorOnly tagged GameObjects in Scenes are no longer detected as duplicates for Scene Analyze results.
- Fixed issue when dragging multiple groups around within the groups window to set their display order.
- Reimplemented AsyncOperationBase.Task API to use TaskComppletionSource instead of creating a background thread.
- Fixed issue where remote .hash file was still being requested when Disable Content Catalog Update on Startup was enabled
- Fixed issue where AssetReference variable names weren't consistently formatted in the inspector
- Fixed bug where Completed callback was not called the same frame for some async operations when WaitForCompletion is used.
- Added Samples to the package.  These can be added to the project through the Addressables page in Package Manager
  • Loading branch information
Unity Technologies committed May 6, 2021
1 parent b1e0e0d commit 59013cd
Show file tree
Hide file tree
Showing 43 changed files with 1,543 additions and 702 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ 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.4] - 2021-05-06
- EditorOnly tagged GameObjects in Scenes are no longer detected as duplicates for Scene Analyze results.
- Fixed issue when dragging multiple groups around within the groups window to set their display order.
- Reimplemented AsyncOperationBase.Task API to use TaskComppletionSource instead of creating a background thread.
- Fixed issue where remote .hash file was still being requested when Disable Content Catalog Update on Startup was enabled
- Fixed issue where AssetReference variable names weren't consistently formatted in the inspector
- Fixed bug where Completed callback was not called the same frame for some async operations when WaitForCompletion is used.
- Added Samples to the package. These can be added to the project through the Addressables page in Package Manager

## [1.18.2] - 2021-04-20
- Where available use synchronous load api's when AsyncOperationHandle.WaitForCompletion is called.
- Fixed issue where loading of Prefabs and ScriptableObjects in "Use Asset Database" and "Simulate Groups" play mode could cause changes to source Assets. Now those play modes will return instanced copies of the Assets.
Expand Down
135 changes: 125 additions & 10 deletions Editor/Build/AnalyzeRules/BundleRuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using UnityEditor.Build.Pipeline;
using UnityEditor.Build.Pipeline.Interfaces;
using UnityEditor.Build.Pipeline.Tasks;
using UnityEditor.Build.Pipeline.Utilities;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.AddressableAssets.Initialization;
using UnityEngine.AddressableAssets.ResourceLocators;
Expand Down Expand Up @@ -131,9 +133,89 @@ internal void IntersectResourcesDepedenciesWithBundleDependencies(List<GUID> bun

internal virtual void BuiltInResourcesToDependenciesMap(string[] resourcePaths)
{
foreach (string path in resourcePaths)
for (int sceneIndex=0; sceneIndex<resourcePaths.Length; ++sceneIndex)
{
string[] dependencies = AssetDatabase.GetDependencies(path);
string path = resourcePaths[sceneIndex];
if (EditorUtility.DisplayCancelableProgressBar("Generating built-in resource dependency map",
"Checking " + path + " for duplicates with Addressables content.",
(float) sceneIndex / resourcePaths.Length))
{
m_ResourcesToDependencies.Clear();
EditorUtility.ClearProgressBar();
return;
}
string[] dependencies;
if (path.EndsWith(".unity"))
{
#if UNITY_2019_3_OR_NEWER
using (var w = new BuildInterfacesWrapper())
{
var usageTags = new BuildUsageTagSet();
BuildSettings settings = new BuildSettings
{
group = EditorUserBuildSettings.selectedBuildTargetGroup,
target = EditorUserBuildSettings.activeBuildTarget,
typeDB = null,
buildFlags = ContentBuildFlags.None
};

SceneDependencyInfo sceneInfo =
ContentBuildInterface.CalculatePlayerDependenciesForScene(path, settings, usageTags);
dependencies = new string[sceneInfo.referencedObjects.Count];
for (int i = 0; i < sceneInfo.referencedObjects.Count; ++i)
{
if (string.IsNullOrEmpty(sceneInfo.referencedObjects[i].filePath))
dependencies[i] = AssetDatabase.GUIDToAssetPath(sceneInfo.referencedObjects[i].guid.ToString());
else
dependencies[i] = sceneInfo.referencedObjects[i].filePath;
}
}
#else
HashSet<string> assetPaths = new HashSet<string>();
assetPaths.Add(path);
var s = EditorSceneManager.OpenScene(path, OpenSceneMode.Additive);
List<UnityEngine.Object> roots = new List<UnityEngine.Object>(s.GetRootGameObjects());

var sceneHierarchyStack = new Stack<GameObject>();
for (int i = roots.Count - 1; i >= 0; --i)
{
GameObject go = (GameObject) roots[i];
if (go.CompareTag("EditorOnly"))
{
UnityEngine.Object.DestroyImmediate(roots[i]);
roots.RemoveAt(i);
}
else
sceneHierarchyStack.Push(go);
}

while (sceneHierarchyStack.Count > 0)
{
var item = sceneHierarchyStack.Pop();
for(int i=0; i<item.transform.childCount; ++i)
{
GameObject go = item.transform.GetChild(i).gameObject;
if (go.CompareTag("EditorOnly"))
UnityEngine.Object.DestroyImmediate(go);
else
sceneHierarchyStack.Push(go);
}
}

UnityEngine.Object[] deps = EditorUtility.CollectDependencies(roots.ToArray());
foreach (UnityEngine.Object o in deps)
{
string p = AssetDatabase.GetAssetPath(o.GetInstanceID());
if (!string.IsNullOrEmpty(p))
assetPaths.Add(p);
}

EditorSceneManager.CloseScene(s, true);
dependencies = assetPaths.ToArray();
#endif
}
else
dependencies = AssetDatabase.GetDependencies(path);

if (!m_ResourcesToDependencies.ContainsKey(path))
m_ResourcesToDependencies.Add(path, new List<GUID>(dependencies.Length));
Expand All @@ -147,6 +229,7 @@ internal virtual void BuiltInResourcesToDependenciesMap(string[] resourcePaths)
m_ResourcesToDependencies[path].Add(new GUID(AssetDatabase.AssetPathToGUID(dependency)));
}
}
EditorUtility.ClearProgressBar();
}

internal void ConvertBundleNamesToGroupNames(AddressableAssetsBuildContext buildContext)
Expand Down Expand Up @@ -183,31 +266,48 @@ internal void ConvertBundleNamesToGroupNames(AddressableAssetsBuildContext build
}
}
}

internal void CalculateInputDefinitions(AddressableAssetSettings settings)
{
foreach (AddressableAssetGroup group in settings.groups)
int updateFrequency = Mathf.Max(settings.groups.Count / 10, 1);
bool progressDisplayed = false;
for (int groupIndex = 0; groupIndex < settings.groups.Count; ++groupIndex)
{
AddressableAssetGroup group = settings.groups[groupIndex];
if (group == null)
continue;

if (!progressDisplayed || groupIndex % updateFrequency == 0)
{
progressDisplayed = true;
if (EditorUtility.DisplayCancelableProgressBar("Calculating Input Definitions", "",
(float) groupIndex / settings.groups.Count))
{
m_AssetEntries.Clear();
m_BundleToAssetGroup.Clear();
m_AllBundleInputDefs.Clear();
break;
}
}

if (group.HasSchema<BundledAssetGroupSchema>())
{
var schema = group.GetSchema<BundledAssetGroupSchema>();
List<AssetBundleBuild> bundleInputDefinitions = new List<AssetBundleBuild>();
m_AssetEntries.AddRange(BuildScriptPackedMode.PrepGroupBundlePacking(group, bundleInputDefinitions, schema));

for (int i = 0; i < bundleInputDefinitions.Count; i++)
{
if (m_BundleToAssetGroup.ContainsKey(bundleInputDefinitions[i].assetBundleName))
bundleInputDefinitions[i] = CreateUniqueBundle(bundleInputDefinitions[i]);

m_BundleToAssetGroup.Add(bundleInputDefinitions[i].assetBundleName, schema.Group.Guid);
}

m_AllBundleInputDefs.AddRange(bundleInputDefinitions);
}
}
if (progressDisplayed)
EditorUtility.ClearProgressBar();
}
internal AssetBundleBuild CreateUniqueBundle(AssetBundleBuild bid)
{
Expand Down Expand Up @@ -268,26 +368,40 @@ internal List<AnalyzeResult> CalculateBuiltInResourceDependenciesToBundleDepende
return results;
}

EditorUtility.DisplayProgressBar("Calculating Built-in dependencies", "Calculating dependencies between Built-in resources and Addressables", 0);
m_AddressableAssets = (from aaGroup in settings.groups
where aaGroup != null
from entry in aaGroup.entries
select new GUID(entry.guid)).ToList();


// bulk of work and progress bars displayed in these methods
BuiltInResourcesToDependenciesMap(builtInResourcesPaths);
if (m_ResourcesToDependencies == null || m_ResourcesToDependencies.Count == 0)
{
results.Add(new AnalyzeResult {resultName = ruleName + " - No issues found."});
return results;
}

CalculateInputDefinitions(settings);
if (m_AllBundleInputDefs == null || m_AllBundleInputDefs.Count == 0)
{
results.Add(new AnalyzeResult {resultName = ruleName + " - No issues found."});
return results;
}
EditorUtility.DisplayProgressBar("Calculating Built-in dependencies", "Calculating dependencies between Built-in resources and Addressables", 0.5f);

var context = GetBuildContext(settings);
ReturnCode exitCode = RefreshBuild(context);
if (exitCode < ReturnCode.Success)
{
Debug.LogError("Analyze build failed. " + exitCode);
results.Add(new AnalyzeResult { resultName = ruleName + "Analyze build failed. " + exitCode });
EditorUtility.ClearProgressBar();
return results;
}

EditorUtility.DisplayProgressBar("Calculating Built-in dependencies", "Calculating dependencies between Built-in resources and Addressables", 0.9f);
IntersectResourcesDepedenciesWithBundleDependencies(GetAllBundleDependencies());

ConvertBundleNamesToGroupNames(context);

results = (from resource in m_ResourcesToDependencies.Keys
Expand All @@ -313,6 +427,7 @@ where m_ExtractData.WriteData.FileToBundle.ContainsKey(file)
if (results.Count == 0)
results.Add(new AnalyzeResult { resultName = ruleName + " - No issues found." });

EditorUtility.ClearProgressBar();
return results;
}

Expand Down
23 changes: 13 additions & 10 deletions Editor/GUI/AddressableAssetsSettingsGroupTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void AddGroupChildrenBuild(AddressableAssetGroup group, TreeViewItem root)
int depth = 0;

AssetEntryTreeViewItem groupItem = null;
if (ProjectConfigData.ShowGroupsAsHierarchy)
if (ProjectConfigData.ShowGroupsAsHierarchy && group != null)
{
//// dash in name imitates hiearchy.
TreeViewItem newRoot = root;
Expand Down Expand Up @@ -1268,17 +1268,20 @@ DragAndDropVisualMode HandleDragAndDropItems(AssetEntryTreeViewItem target, Drag
{
if (args.parentItem == null || args.parentItem == rootItem && visualMode != DragAndDropVisualMode.Rejected)
{
AddressableAssetGroup group = draggedNodes.First().@group;
int index = m_Editor.settings.groups.FindIndex(g => g == group);
if (index < args.insertAtIndex)
args.insertAtIndex--;
foreach (var node in draggedNodes)
{
AddressableAssetGroup group = node.@group;
int index = m_Editor.settings.groups.FindIndex(g => g == group);
if (index < args.insertAtIndex)
args.insertAtIndex--;

m_Editor.settings.groups.RemoveAt(index);
m_Editor.settings.groups.RemoveAt(index);

if (args.insertAtIndex < 0 || args.insertAtIndex > m_Editor.settings.groups.Count)
m_Editor.settings.groups.Insert(m_Editor.settings.groups.Count, group);
else
m_Editor.settings.groups.Insert(args.insertAtIndex, group);
if (args.insertAtIndex < 0 || args.insertAtIndex > m_Editor.settings.groups.Count)
m_Editor.settings.groups.Insert(m_Editor.settings.groups.Count, group);
else
m_Editor.settings.groups.Insert(args.insertAtIndex, group);
}

m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.GroupMoved, m_Editor.settings.groups, true, true);
Reload();
Expand Down
Loading

0 comments on commit 59013cd

Please sign in to comment.