MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetTypeDisplayName

Method GetTypeDisplayName

Source/Editor/Scripting/TypeUtils.cs:41–76  ·  view source on GitHub ↗

Gets the typename name for UI. The type. The display of the type.

(this Type type)

Source from the content-addressed store, hash-verified

39 /// <param name="type">The type.</param>
40 /// <returns>The display of the type.</returns>
41 public static string GetTypeDisplayName(this Type type)
42 {
43 // Special display for in-built basic types
44 if (type == null)
45 return "Null";
46 if (type == typeof(bool))
47 return "Bool";
48 if (type == typeof(float))
49 return "Float";
50 if (type == typeof(int))
51 return "Int";
52 if (type == typeof(uint))
53 return "Uint";
54
55 // For generic types (eg. Dictionary) Name returns generic parameter types with fully qualified name so simplify it manually
56 if (type.IsGenericType)
57 {
58 var sb = new StringBuilder();
59 var name = type.Name;
60 var idx = name.IndexOf('`');
61 sb.Append(idx != -1 ? name.Substring(0, idx) : name);
62 sb.Append('<');
63 var genericArgs = type.GetGenericArguments();
64 for (var i = 0; i < genericArgs.Length; i++)
65 {
66 if (i != 0)
67 sb.Append(", ");
68 sb.Append(genericArgs[i].GetTypeDisplayName());
69 }
70 sb.Append('>');
71 return sb.ToString();
72 }
73
74 // Default name
75 return type.Name;
76 }
77
78 /// <summary>
79 /// Gets the default value for the given type (can be value type or reference type).

Callers 6

ReadVariantMethod · 0.80
WriteVariantMethod · 0.80
UpdateFilterMethod · 0.80
DrawMethod · 0.80
ScriptTypeClass · 0.80
ToStringMethod · 0.80

Calls 5

SubstringMethod · 0.80
GetGenericArgumentsMethod · 0.80
IndexOfMethod · 0.45
AppendMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected