Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
// todo: serialize/deserialize when not changed? After switching to the scriptable build pipeline this is already done, so NO.
var typeDB = results.typeDB;
return typeDB;
}
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.