diff --git a/Addons/Entitas.VisualDebugging.Unity.Editor/Entitas.VisualDebugging.Unity.Editor/Entity/Entity/EntityDrawer.cs b/Addons/Entitas.VisualDebugging.Unity.Editor/Entitas.VisualDebugging.Unity.Editor/Entity/Entity/EntityDrawer.cs index a8081a9f2..ce8a34dd6 100644 --- a/Addons/Entitas.VisualDebugging.Unity.Editor/Entitas.VisualDebugging.Unity.Editor/Entity/Entity/EntityDrawer.cs +++ b/Addons/Entitas.VisualDebugging.Unity.Editor/Entitas.VisualDebugging.Unity.Editor/Entity/Entity/EntityDrawer.cs @@ -164,7 +164,11 @@ public static void DrawComponents(IEntity entity) public static void DrawComponent(bool[] unfoldedComponents, string[] componentMemberSearch, IEntity entity, int index, IComponent component) { var componentType = component.GetType(); - var componentName = componentType.Name.RemoveComponentSuffix(); + var customNameProvider = component as ICustomDisplayName; + var componentName = customNameProvider != null + ? customNameProvider.DisplayName + : TypeHelper.GetTypeName(componentType).RemoveComponentSuffix(); + if (EditorLayout.MatchesSearchString(componentName.ToLower(), componentNameSearchString.ToLower())) { var boxStyle = getColoredBoxStyle(entity, index); diff --git a/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity.csproj b/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity.csproj index ac01f5f3c..ab1f51f4c 100644 --- a/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity.csproj +++ b/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity.csproj @@ -44,6 +44,8 @@ + + @@ -51,8 +53,6 @@ Entitas - - - + \ No newline at end of file diff --git a/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/DebugSystems/SystemInfo.cs b/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/DebugSystems/SystemInfo.cs index eb6569b7f..0345a929f 100644 --- a/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/DebugSystems/SystemInfo.cs +++ b/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/DebugSystems/SystemInfo.cs @@ -62,9 +62,22 @@ public SystemInfo(ISystem system) { _interfaceFlags = getInterfaceFlags(system); var debugSystem = system as DebugSystems; - _systemName = debugSystem != null - ? debugSystem.name - : system.GetType().Name.RemoveSystemSuffix(); + if (debugSystem != null) + { + _systemName = debugSystem.name; + } + else + { + var customNameProvider = system as ICustomDisplayName; + if (customNameProvider != null) + { + _systemName = customNameProvider.DisplayName; + } + else + { + _systemName = TypeHelper.GetTypeName(system.GetType()).RemoveSystemSuffix(); + } + } isActive = true; } diff --git a/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/ICustomDisplayName.cs b/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/ICustomDisplayName.cs new file mode 100644 index 000000000..036f33a5d --- /dev/null +++ b/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/ICustomDisplayName.cs @@ -0,0 +1,7 @@ +namespace Entitas.VisualDebugging.Unity +{ + public interface ICustomDisplayName + { + string DisplayName { get; } + } +} diff --git a/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/TypeHelper.cs b/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/TypeHelper.cs new file mode 100644 index 000000000..cded38560 --- /dev/null +++ b/Addons/Entitas.VisualDebugging.Unity/Entitas.VisualDebugging.Unity/TypeHelper.cs @@ -0,0 +1,30 @@ +using System; + +namespace Entitas.VisualDebugging.Unity +{ + public static class TypeHelper + { + /// + /// Returns a type name including generic type parameters. + /// + public static string GetTypeName(Type type) + { + if (type.IsGenericType) + { + var simpleName = type.Name.Substring(0, type.Name.IndexOf('`')); + string genericTypeParams = string.Empty; + var args = !type.IsGenericTypeDefinition + ? type.GetGenericArguments() + : Type.EmptyTypes; + + for (int i = 0; i < args.Length; i++) + { + if (i > 0) genericTypeParams += ","; + genericTypeParams += GetTypeName(args[i]); + } + return string.Format("{0}<{1}>", simpleName, genericTypeParams); + } + return type.Name; + } + } +}