(Case 1179898) - Unity 2019.3.0b1:
EditorUtility.CollectDependencies now always returns null independent of input.
1 Like
For anyone interested: Workaround using the new API’s:
static HashSet<AssetPath> GetDependencies(string assetPath, BuildTarget buildTarget, TypeDB typeDB)
{
var guid = new GUID(AssetDatabase.AssetPathToGUID(assetPath));
var ids = ContentBuildInterface.GetPlayerObjectIdentifiersInAsset(guid, buildTarget);
var deps = ContentBuildInterface.GetPlayerDependenciesForObjects(ids, buildTarget, typeDB);
var dependencies = new HashSet<string>();
foreach (var dep in deps)
{
var path = "";
if (dep.fileType == FileType.SerializedAssetType)
path = dep.filePath;
else if (dep.fileType == FileType.MetaAssetType)
path = AssetDatabase.GUIDToAssetPath(dep.guid.ToString());
if (string.IsNullOrEmpty(path))
continue;
dependencies.Add(path);
}
return dependencies;
}
static TypeDB GetTypeDB(BuildTarget buildTarget)
{
BuildTargetGroup group;
if (!Enum<BuildTargetGroup>.TryParse(buildTarget.ToString(), out group))
group = BuildTargetGroup.Standalone;
var settings = new ScriptCompilationSettings
{
target = buildTarget,
group = group,
options = ScriptCompilationOptions.None,
};
var tempPath = ".temp/AssetBundleHelper_Compile";
if (Directory.Exists(tempPath))
Directory.Delete(tempPath, true);
var results = PlayerBuildInterface.CompilePlayerScripts(settings, tempPath);
var typeDB = results.typeDB;
return typeDB;
}
Note: GetTypeDB must be cached as it executes a compilation step for the standalone libraries which takes some time.
2 Likes
This issue should be fixed in 2019.3.0b3.
Sigh
At least there is a temporary work around and it is confirmed as fixed ![]()
