protected override object _DeserializeArray(string name, FFieldInfo info, SerializeTool tool, bool isArray) { IList list = null; int count = tool.PopArrayHead(); EditorGUILayout.LabelField("数组个数:" + count); if (isArray) { list = Array.CreateInstance(info.GenericType1.ClassType, count); } else { Type[] tempTypes = info.ClassType.GetGenericArguments(); var listType = typeof(List <>).MakeGenericType(tempTypes); list = (IList)Activator.CreateInstance(listType); } if (isArray) { for (int i = 0; i < count; i++) { tool.ArrayIndexToName(i); list[i] = _Deserialize(" 元素" + i.ToString(), info.GenericType1, tool, null); } } else { for (int i = 0; i < count; i++) { tool.ArrayIndexToName(i); list.Add(_Deserialize(" 元素" + i.ToString(), info.GenericType1, tool, null)); } } EditorGUILayout.LabelField("---------------数组结束--------------------"); if (GUILayout.Button("添加元素")) { if (isArray) { Array newArray = Array.CreateInstance(info.GenericType1.ClassType, count + 1); if (count != 0) { Array.Copy((Array)list, newArray, count); } list = newArray; list[count] = CreateInstance(info.GenericType1); } else { if (count == 0) { var listType = typeof(List <>).MakeGenericType(info.GenericType1.ClassType); list = (IList)Activator.CreateInstance(listType); } list.Add(CreateInstance(info.GenericType1)); } } if (count != 0) { if (GUILayout.Button("删除元素")) { if (isArray) { if (count != 0) { Array newArray = Array.CreateInstance(info.GenericType1.ClassType, count - 1); if (count - 1 > 0) { Array.Copy((Array)list, newArray, count - 1); } list = newArray; } } else { if (count != 0) { list.RemoveAt(count - 1); } } } } return(list); }