using System.Collections.Generic;
using System.Linq;
using AssetBank.Editor.SchemaConverter.Data.Input;
namespace AssetBank.Editor.SchemaConverter.Processors
{
///
/// Handles the logic for processing PrefabInstance nodes.
///
public static class PrefabProcessor
{
///
/// Creates a list of unique prefab GUIDs from all PrefabInstance nodes.
///
/// A list of all PrefabInstance nodes.
/// A list of unique GUID strings.
public static (List guids, List warnings) Process(IReadOnlyList prefabInstances)
{
var warnings = new List();
var uniqueGuids = new HashSet();
foreach (var instance in prefabInstances)
{
var guid = instance.data?["PrefabInstance"]?["m_SourcePrefab"]?["guid"]?.ToString();
if (!string.IsNullOrEmpty(guid))
{
uniqueGuids.Add(guid);
}
else
{
warnings.Add($"Found a PrefabInstance with anchor_id '{instance.anchor_id}' that is missing a source prefab GUID.");
}
}
return (uniqueGuids.ToList(), warnings);
}
}
}