Ejemplo n.º 1
0
        /// <summary>
        /// Registers a new row in the layout for the provided property. The type of row is determined by the property type.
        /// </summary>
        /// <param name="parent">Parent foldout row to which to append the new elements.</param>
        /// <param name="name">Name of the field the property belongs to.</param>
        /// <param name="path">Slash separated path to the field from its parent object.</param>
        /// <param name="property">Property to create the row for.</param>
        /// <param name="element">Element containing data for the newly created row. Only valid if method returns true.
        ///                       </param>
        /// <returns>Returns true if the row was successfully added, false otherwise.</returns>
        private bool AddPropertyRow(Element parent, string name, string path, SerializableProperty property,
                                    out Element element)
        {
            switch (property.Type)
            {
            case SerializableProperty.FieldType.Bool:
            case SerializableProperty.FieldType.Float:
            case SerializableProperty.FieldType.Int:
            case SerializableProperty.FieldType.Color:
            case SerializableProperty.FieldType.Vector2:
            case SerializableProperty.FieldType.Vector3:
            case SerializableProperty.FieldType.Vector4:
                element = AddFieldRow(parent.childLayout, name, parent.so, parent.comp, path, property.Type);
                return(true);

            case SerializableProperty.FieldType.Object:
            {
                Action <Element, bool> toggleCallback =
                    (toggleParent, expand) =>
                {
                    SerializableObject childObject = new SerializableObject(property.InternalType, null);
                    ToggleObjectFoldout(toggleParent, childObject, expand);
                };

                element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback);
            }
                return(true);

            case SerializableProperty.FieldType.Array:
            {
                Action <Element, bool> toggleCallback =
                    (toggleParent, expand) =>
                {
                    SerializableArray childObject = property.GetArray();

                    if (childObject != null)
                    {
                        ToggleArrayFoldout(toggleParent, childObject, expand);
                    }
                };

                element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback);
            }
                return(true);

            case SerializableProperty.FieldType.List:
            {
                Action <Element, bool> toggleCallback =
                    (toggleParent, expand) =>
                {
                    SerializableList childObject = property.GetList();

                    if (childObject != null)
                    {
                        ToggleListFoldout(toggleParent, childObject, expand);
                    }
                };

                element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback);
            }
                return(true);
            }

            element = new Element();
            return(false);
        }
Ejemplo n.º 2
0
            /// <inheritdoc/>
            protected internal override object GetValue(int seqIndex)
            {
                SerializableList list = property.GetList();

                return(list.GetProperty(seqIndex));
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Registers a new row in the layout for the provided property. The type of row is determined by the property type.
        /// </summary>
        /// <param name="parent">Parent foldout row to which to append the new elements.</param>
        /// <param name="name">Name of the field the property belongs to.</param>
        /// <param name="path">Slash separated path to the field from its parent object.</param>
        /// <param name="property">Property to create the row for.</param>
        /// <param name="element">Element containing data for the newly created row. Only valid if method returns true.
        ///                       </param>
        /// <returns>Returns true if the row was successfully added, false otherwise.</returns>
        private bool AddPropertyRow(Element parent, string name, string path, SerializableProperty property, 
            out Element element)
        {
            switch (property.Type)
            {
                case SerializableProperty.FieldType.Bool:
                case SerializableProperty.FieldType.Float:
                case SerializableProperty.FieldType.Int:
                case SerializableProperty.FieldType.Color:
                case SerializableProperty.FieldType.Vector2:
                case SerializableProperty.FieldType.Vector3:
                case SerializableProperty.FieldType.Vector4:
                    element = AddFieldRow(parent.childLayout, name, parent.so, parent.comp, path, property.Type);
                    return true;
                case SerializableProperty.FieldType.Object:
                    {
                        Action<Element, bool> toggleCallback =
                            (toggleParent, expand) =>
                            {
                                SerializableObject childObject = new SerializableObject(property.InternalType, null);
                                ToggleObjectFoldout(toggleParent, childObject, expand);
                            };

                        element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback);
                    }
                    return true;
                case SerializableProperty.FieldType.Array:
                    {
                        Action<Element, bool> toggleCallback =
                            (toggleParent, expand) =>
                            {
                                SerializableArray childObject = property.GetArray();

                                if (childObject != null)
                                    ToggleArrayFoldout(toggleParent, childObject, expand);
                            };

                        element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback);
                    }
                    return true;
                case SerializableProperty.FieldType.List:
                    {
                        Action<Element, bool> toggleCallback =
                            (toggleParent, expand) =>
                            {
                                SerializableList childObject = property.GetList();

                                if (childObject != null)
                                    ToggleListFoldout(toggleParent, childObject, expand);
                            };

                        element = AddFoldoutRow(parent.childLayout, null, name, parent.so, parent.comp, path, toggleCallback);
                    }
                    return true;
            }

            element = new Element();
            return false;
        }