This commit is contained in:
vis2k 2021-09-25 16:17:49 +08:00
parent d9bdc954cf
commit e7f04d620d

View File

@ -7,13 +7,13 @@
namespace Mirror
{
class EnuerableSyncObjectField
class EnumerableSyncObjectField
{
public bool visible;
public readonly FieldInfo field;
public readonly string label;
public EnuerableSyncObjectField(FieldInfo field)
public EnumerableSyncObjectField(FieldInfo field)
{
this.field = field;
visible = false;
@ -24,17 +24,17 @@ public EnuerableSyncObjectField(FieldInfo field)
public class EnumerableSyncObjectDrawer
{
readonly UnityEngine.Object targetObject;
readonly List<EnuerableSyncObjectField> enumerableSyncObjectFields;
readonly List<EnumerableSyncObjectField> enumerableSyncObjectFields;
public EnumerableSyncObjectDrawer(UnityEngine.Object targetObject)
{
this.targetObject = targetObject;
enumerableSyncObjectFields = new List<EnuerableSyncObjectField>();
enumerableSyncObjectFields = new List<EnumerableSyncObjectField>();
foreach (FieldInfo field in InspectorHelper.GetAllFields(targetObject.GetType(), typeof(NetworkBehaviour)))
{
if (field.ImplementsInterface<SyncObject>() && field.IsVisibleInInspector())
{
enumerableSyncObjectFields.Add(new EnuerableSyncObjectField(field));
enumerableSyncObjectFields.Add(new EnumerableSyncObjectField(field));
}
}
}
@ -52,14 +52,14 @@ public void Draw()
}
}
void DrawEnumerableSyncObject(EnuerableSyncObjectField enuerableSyncObjectField)
void DrawEnumerableSyncObject(EnumerableSyncObjectField enumerableSyncObjectField)
{
enuerableSyncObjectField.visible = EditorGUILayout.Foldout(enuerableSyncObjectField.visible, enuerableSyncObjectField.label);
if (enuerableSyncObjectField.visible)
enumerableSyncObjectField.visible = EditorGUILayout.Foldout(enumerableSyncObjectField.visible, enumerableSyncObjectField.label);
if (enumerableSyncObjectField.visible)
{
using (new EditorGUI.IndentLevelScope())
{
object fieldValue = enuerableSyncObjectField.field.GetValue(targetObject);
object fieldValue = enumerableSyncObjectField.field.GetValue(targetObject);
if (fieldValue is IEnumerable syncObject)
{
int index = 0;