/// <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);
        }
Exemplo n.º 2
0
        /// <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();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Expands or collapses the set of rows displaying all entries of a serializable array.
        /// </summary>
        /// <param name="parent">Parent row element whose children to expand/collapse.</param>
        /// <param name="obj">Object describing the array whose entries to display.</param>
        /// <param name="expand">True to expand, false to collapse.</param>
        private void ToggleArrayFoldout(Element parent, SerializableArray obj,
            bool expand)
        {
            parent.childLayout.Clear();
            parent.children = null;

            parent.indentLayout.Active = expand;

            if (expand)
                AddArrayRows(parent, obj);
        }