mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 14:02:55 +08:00
Merge pull request #17448 from peppy/fix-skin-component-crash-on-instantiation-failure
Avoid crashing if a skin component cannot be instantiated correctly
This commit is contained in:
commit
6c172bac3c
@ -152,9 +152,23 @@ namespace osu.Game.Skinning
|
|||||||
if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo))
|
if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
var components = new List<Drawable>();
|
||||||
|
|
||||||
|
foreach (var i in skinnableInfo)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
components.Add(i.CreateInstance());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Error(e, $"Unable to create skin component {i.Type.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new SkinnableTargetComponentsContainer
|
return new SkinnableTargetComponentsContainer
|
||||||
{
|
{
|
||||||
ChildrenEnumerable = skinnableInfo.Select(i => i.CreateInstance())
|
Children = components,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user