/// <inheritdoc/> protected internal override void CloneElement(int index) { SerializableArray array = property.GetArray(); int size = array.GetLength() + 1; Array newArray = property.CreateArrayInstance(new int[] { size }); object clonedEntry = null; for (int i = 0; i < array.GetLength(); i++) { object value = array.GetProperty(i).GetValue <object>(); newArray.SetValue(value, i); if (i == index) { clonedEntry = SerializableUtility.Clone(array.GetProperty(i).GetValue <object>()); } } newArray.SetValue(clonedEntry, size - 1); property.SetValue(newArray); this.array = newArray; numElements = newArray.Length; }
/// <summary> /// Registers a set of rows for all entries of the provided array. /// </summary> /// <param name="parent">Parent foldout row to which to append the new elements.</param> /// <param name="serializableArray">Array whose fields to display.</param> private void AddArrayRows(Element parent, SerializableArray serializableArray) { List <Element> elements = new List <Element>(); int length = serializableArray.GetLength(); for (int i = 0; i < length; i++) { string name = "[" + i + "]"; string propertyPath = parent.path + name; Element element; if (AddPropertyRow(parent, name, propertyPath, serializableArray.GetProperty(i), out element)) { elements.Add(element); } } parent.children = elements.ToArray(); }