fix(SyncObjectCollectionField): Pretty SyncCollection Name (#3808)

* fix(SyncObjectCollectionField): Pretty SyncCollection Name

* char typo

* backward compatibility

* Use RegEx.Replace
This commit is contained in:
MrGadget 2024-04-23 23:57:16 -04:00
parent 4a1be60ad7
commit 9e7b82135c

View File

@ -4,6 +4,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEditor;
namespace Mirror
@ -18,7 +19,12 @@ public SyncObjectCollectionField(FieldInfo field)
{
this.field = field;
visible = false;
label = $"{field.Name} [{field.FieldType.Name}]";
// field.FieldType.Name has a backtick and number at the end, e.g. SyncList`1
// so we split it and only take the first part so it looks nicer.
// e.g. SyncList`1 -> SyncList
// Better to do it one time here than in hot path in OnInspectorGUI
label = $"{field.Name} [{Regex.Replace(field.FieldType.Name, @"`\d+", "")}]";
}
}