From fe6c254a2496889fce842e42cdcab864ba3e9600 Mon Sep 17 00:00:00 2001
From: Menotdan <32620310+Menotdan@users.noreply.github.com>
Date: Wed, 10 Apr 2024 18:47:01 -0400
Subject: [PATCH] Support displaying "Widget" instead of "Prefab" in the type
description.
---
Source/Editor/Content/Items/PrefabItem.cs | 26 +++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/Source/Editor/Content/Items/PrefabItem.cs b/Source/Editor/Content/Items/PrefabItem.cs
index a61e07e7c..6394ed52c 100644
--- a/Source/Editor/Content/Items/PrefabItem.cs
+++ b/Source/Editor/Content/Items/PrefabItem.cs
@@ -42,6 +42,32 @@ namespace FlaxEditor.Content
///
public override SpriteHandle DefaultThumbnail => SpriteHandle.Invalid;
+ private string _cachedTypeDescription = null;
+
+ ///
+ public override string TypeDescription
+ {
+ get
+ {
+ if (_cachedTypeDescription != null)
+ return _cachedTypeDescription;
+
+ Prefab prefab = FlaxEngine.Content.LoadAsync(ID);
+ if (prefab.WaitForLoaded(5000))
+ {
+ _cachedTypeDescription = "Prefab";
+ }
+
+ Actor root = prefab.GetDefaultInstance();
+ if (root is UIControl or UICanvas)
+ _cachedTypeDescription = "Widget";
+ else
+ _cachedTypeDescription = "Prefab";
+
+ return _cachedTypeDescription;
+ }
+ }
+
///
public override bool IsOfType(Type type)
{