Support displaying "Widget" instead of "Prefab" in the type description.

This commit is contained in:
Menotdan
2024-04-10 18:47:01 -04:00
parent 8ef38178e6
commit fe6c254a24

View File

@@ -42,6 +42,32 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override SpriteHandle DefaultThumbnail => SpriteHandle.Invalid;
private string _cachedTypeDescription = null;
/// <inheritdoc />
public override string TypeDescription
{
get
{
if (_cachedTypeDescription != null)
return _cachedTypeDescription;
Prefab prefab = FlaxEngine.Content.LoadAsync<Prefab>(ID);
if (prefab.WaitForLoaded(5000))
{
_cachedTypeDescription = "Prefab";
}
Actor root = prefab.GetDefaultInstance();
if (root is UIControl or UICanvas)
_cachedTypeDescription = "Widget";
else
_cachedTypeDescription = "Prefab";
return _cachedTypeDescription;
}
}
/// <inheritdoc />
public override bool IsOfType(Type type)
{