/// <summary>
        /// Registers a new row in the layout. The row cannot be selected as the output field, but rather can be expanded
        /// so it displays child elements.
        /// </summary>
        /// <param name="layout">Layout to append the row GUI elements to.</param>
        /// <param name="icon">Optional icon to display next to the name. Can be null.</param>
        /// <param name="name">Name of the field.</param>
        /// <param name="so">Parent scene object of the field.</param>
        /// <param name="component">Parent component of the field. Can be null if field belongs to <see cref="SceneObject"/>.
        ///                         </param>
        /// <param name="path">Slash separated path to the field from its parent object.</param>
        /// <param name="toggleCallback">Callback to trigger when the user expands or collapses the foldout.</param>
        /// <returns>Element object storing all information about the added field.</returns>
        private Element AddFoldoutRow(GUILayout layout, SpriteTexture icon, string name, SceneObject so, Component component,
            string path, Action<Element, bool> toggleCallback)
        {
            Element element = new Element(so, component, path);

            GUILayoutY elementLayout = layout.AddLayoutY();
            GUILayoutX foldoutLayout = elementLayout.AddLayoutX();

            element.toggle = new GUIToggle("", EditorStyles.Expand);
            element.toggle.OnToggled += x => toggleCallback(element, x);

            foldoutLayout.AddSpace(PADDING);
            foldoutLayout.AddElement(element.toggle);

            if (icon != null)
            {
                GUITexture guiIcon = new GUITexture(icon, GUIOption.FixedWidth(16), GUIOption.FixedWidth(16));
                foldoutLayout.AddElement(guiIcon);
            }

            GUILabel label = new GUILabel(new LocEdString(name));
            foldoutLayout.AddElement(label);
            foldoutLayout.AddFlexibleSpace();

            element.indentLayout = elementLayout.AddLayoutX();
            element.indentLayout.AddSpace(INDENT_AMOUNT);
            element.childLayout = element.indentLayout.AddLayoutY();

            element.indentLayout.Active = false;

            return element;
        }
            public Element(SceneObject so, Component comp, string path)
            {
                this.so = so;
                this.comp = comp;
                this.path = path;

                toggle = null;
                childLayout = null;
                indentLayout = null;

                children = null;
            }
        /// <summary>
        /// Registers a new row in the layout. The row cannot have any further children and can be selected as the output
        /// field.
        /// </summary>
        /// <param name="layout">Layout to append the row GUI elements to.</param>
        /// <param name="name">Name of the field.</param>
        /// <param name="so">Parent scene object of the field.</param>
        /// <param name="component">Parent component of the field. Can be null if field belongs to <see cref="SceneObject"/>.
        ///                         </param>
        /// <param name="path">Slash separated path to the field from its parent object.</param>
        /// <param name="type">Data type stored in the field.</param>
        /// <returns>Element object storing all information about the added field.</returns>
        private Element AddFieldRow(GUILayout layout, string name, SceneObject so, Component component, string path, SerializableProperty.FieldType type)
        {
            Element element = new Element(so, component, path);

            GUILayoutX elementLayout = layout.AddLayoutX();

            elementLayout.AddSpace(PADDING);
            elementLayout.AddSpace(foldoutWidth);
            GUILabel label = new GUILabel(new LocEdString(name));
            elementLayout.AddElement(label);

            GUIButton selectBtn = new GUIButton(new LocEdString("Select"));
            selectBtn.OnClick += () => { DoOnElementSelected(element, type); };

            elementLayout.AddFlexibleSpace();
            elementLayout.AddElement(selectBtn);
            elementLayout.AddSpace(5);

            element.path = path;

            return element;
        }