Fix deserialise failing with some old skins

This commit is contained in:
Dean Herbert 2024-08-23 20:44:45 +09:00
parent 3943fe96f4
commit 885d832e98
No known key found for this signature in database
1 changed files with 24 additions and 0 deletions

View File

@ -248,9 +248,33 @@ public void UpdateDrawableTarget(SkinnableContainer targetContainer)
applyMigration(layout, target, i);
layout.Version = SkinLayoutInfo.LATEST_VERSION;
foreach (var kvp in layout.DrawableInfo.ToArray())
{
foreach (var di in kvp.Value)
{
if (!isValidDrawable(di))
layout.DrawableInfo[kvp.Key] = kvp.Value.Where(i => i.Type != di.Type).ToArray();
}
}
return layout;
}
private bool isValidDrawable(SerialisedDrawableInfo di)
{
if (!typeof(ISerialisableDrawable).IsAssignableFrom(di.Type))
return false;
foreach (var child in di.Children)
{
if (!isValidDrawable(child))
return false;
}
return true;
}
private void applyMigration(SkinLayoutInfo layout, GlobalSkinnableContainers target, int version)
{
switch (version)