/// <summary> /// Helper method used for finding child properties of the specified property, using a property path. /// <see cref="SerializableObject.FindProperty(string)"/>. /// </summary> /// <param name="pathElements">Path elements representing field names and keys to look for.</param> /// <param name="elementIdx">Index in the <paramref name="pathElements"/> array to start the search at.</param> /// <returns>Property representing the final path element, or null if not found (array index is out of range, or /// property with that path doesn't exist).</returns> internal SerializableProperty FindProperty(PropertyPathElement[] pathElements, int elementIdx) { switch (type) { case FieldType.Object: { SerializableObject childObject = GetObject(); return(childObject.FindProperty(pathElements, elementIdx)); } case FieldType.Array: { SerializableArray childArray = GetArray(); return(childArray.FindProperty(pathElements, elementIdx)); } case FieldType.List: { SerializableList childList = GetList(); return(childList.FindProperty(pathElements, elementIdx)); } case FieldType.Dictionary: { SerializableDictionary childDictionary = GetDictionary(); return(childDictionary.FindProperty(pathElements, elementIdx)); } } return(null); }
/// <summary> /// Expands or collapses the set of rows displaying all entries of a serializable list. /// </summary> /// <param name="parent">Parent row element whose children to expand/collapse.</param> /// <param name="obj">Object describing the list whose entries to display.</param> /// <param name="expand">True to expand, false to collapse.</param> private void ToggleListFoldout(Element parent, SerializableList obj, bool expand) { parent.childLayout.Clear(); parent.children = null; parent.indentLayout.Active = expand; if (expand) AddListRows(parent, obj); }
/// <summary> /// Registers a set of rows for all entries of the provided list. /// </summary> /// <param name="parent">Parent foldout row to which to append the new elements.</param> /// <param name="serializableList">List whose fields to display.</param> private void AddListRows(Element parent, SerializableList serializableList) { List<Element> elements = new List<Element>(); int length = serializableList.GetLength(); for (int i = 0; i < length; i++) { string name = "[" + i + "]"; string propertyPath = parent.path + name; Element element; if (AddPropertyRow(parent, name, propertyPath, serializableList.GetProperty(i), out element)) elements.Add(element); } parent.children = elements.ToArray(); }