Exemple #1
0
        /// <inheritdoc/>
        protected internal override void Initialize(int index)
        {
            guiLayout = layout.AddLayoutY(index);

            GUILayoutX guiTitleLayout = guiLayout.AddLayoutX();

            GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout);

            guiFoldout.Value           = isExpanded;
            guiFoldout.AcceptsKeyFocus = false;
            guiFoldout.OnToggled      += OnFoldoutToggled;
            guiTitleLayout.AddElement(guiFoldout);

            GUILayoutX categoryContentLayout = guiLayout.AddLayoutX();

            categoryContentLayout.AddSpace(IndentAmount);

            guiContentPanel = categoryContentLayout.AddPanel();
            GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX();

            guiIndentLayoutX.AddSpace(IndentAmount);
            GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();

            guiIndentLayoutY.AddSpace(IndentAmount);
            ChildLayout = guiIndentLayoutY.AddLayoutY();
            guiIndentLayoutY.AddSpace(IndentAmount);
            guiIndentLayoutX.AddSpace(IndentAmount);
            categoryContentLayout.AddSpace(IndentAmount);

            short  backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
            string bgPanelStyle    = depth % 2 == 0
                ? EditorStylesInternal.InspectorContentBgAlternate
                : EditorStylesInternal.InspectorContentBg;
            GUIPanel   backgroundPanel    = guiContentPanel.AddPanel(backgroundDepth);
            GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);

            backgroundPanel.AddElement(inspectorContentBg);

            guiContentPanel.Active = isExpanded;
        }
Exemple #2
0
        /// <summary>
        /// Rebuilds the GUI list header if needed.
        /// </summary>
        protected void UpdateHeaderGUI()
        {
            Action BuildEmptyGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                guiInternalTitleLayout.AddElement(new GUILabel(title));
                guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100)));

                GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create),
                                                       new LocEdString("Create"));
                GUIButton createBtn = new GUIButton(createIcon, GUIOption.FixedWidth(30));
                createBtn.OnClick += OnCreateButtonClicked;
                guiInternalTitleLayout.AddElement(createBtn);
            };

            Action BuildFilledGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout);
                guiFoldout.Value      = isExpanded;
                guiFoldout.OnToggled += ToggleFoldout;
                guiSizeField          = new GUIIntField("", GUIOption.FixedWidth(50));
                guiSizeField.SetRange(0, int.MaxValue);

                GUIContent resizeIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Resize),
                                                       new LocEdString("Resize"));
                GUIButton guiResizeBtn = new GUIButton(resizeIcon, GUIOption.FixedWidth(30));
                guiResizeBtn.OnClick += OnResizeButtonClicked;

                GUIContent clearIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear),
                                                      new LocEdString("Clear"));
                GUIButton guiClearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(30));
                guiClearBtn.OnClick += OnClearButtonClicked;

                guiInternalTitleLayout.AddElement(guiFoldout);
                guiInternalTitleLayout.AddElement(guiSizeField);
                guiInternalTitleLayout.AddElement(guiResizeBtn);
                guiInternalTitleLayout.AddElement(guiClearBtn);

                guiSizeField.Value = GetNumRows();

                guiChildLayout = guiLayout.AddLayoutX();
                guiChildLayout.AddSpace(IndentAmount);
                guiChildLayout.Active = isExpanded;

                GUIPanel   guiContentPanel  = guiChildLayout.AddPanel();
                GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX();
                guiIndentLayoutX.AddSpace(IndentAmount);
                GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();
                guiIndentLayoutY.AddSpace(IndentAmount);
                guiContentLayout = guiIndentLayoutY.AddLayoutY();
                guiIndentLayoutY.AddSpace(IndentAmount);
                guiIndentLayoutX.AddSpace(IndentAmount);
                guiChildLayout.AddSpace(IndentAmount);

                short  backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
                string bgPanelStyle    = depth % 2 == 0
                    ? EditorStyles.InspectorContentBgAlternate
                    : EditorStyles.InspectorContentBg;

                GUIPanel   backgroundPanel    = guiContentPanel.AddPanel(backgroundDepth);
                GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                backgroundPanel.AddElement(inspectorContentBg);
            };

            if (state == State.None)
            {
                if (!IsNull())
                {
                    BuildFilledGUI();
                    state = State.Filled;
                }
                else
                {
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
            else if (state == State.Empty)
            {
                if (!IsNull())
                {
                    guiInternalTitleLayout.Destroy();
                    BuildFilledGUI();
                    state = State.Filled;
                }
            }
            else if (state == State.Filled)
            {
                if (IsNull())
                {
                    guiInternalTitleLayout.Destroy();
                    guiChildLayout.Destroy();
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Rebuilds the GUI object header if needed.
        /// </summary>
        /// <param name="layoutIndex">Index at which to insert the GUI elements.</param>
        protected void BuildGUI(int layoutIndex)
        {
            Action BuildEmptyGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                guiInternalTitleLayout.AddElement(new GUILabel(title));
                guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100)));

                if (!property.IsValueType)
                {
                    GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create),
                                                           new LocEdString("Create"));
                    guiCreateBtn          = new GUIButton(createIcon, GUIOption.FixedWidth(30));
                    guiCreateBtn.OnClick += OnCreateButtonClicked;
                    guiInternalTitleLayout.AddElement(guiCreateBtn);
                }
            };

            Action BuildFilledGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout);
                guiFoldout.Value           = isExpanded;
                guiFoldout.AcceptsKeyFocus = false;
                guiFoldout.OnToggled      += OnFoldoutToggled;
                guiInternalTitleLayout.AddElement(guiFoldout);

                if (!style.StyleFlags.HasFlag(InspectableFieldStyleFlags.NotNull))
                {
                    GUIContent clearIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear),
                                                          new LocEdString("Clear"));
                    GUIButton clearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(20));
                    clearBtn.OnClick += OnClearButtonClicked;
                    guiInternalTitleLayout.AddElement(clearBtn);
                }

                if (isExpanded)
                {
                    SerializableObject  serializableObject = property.GetObject();
                    SerializableField[] fields             = serializableObject.Fields;

                    if (fields.Length > 0)
                    {
                        guiChildLayout = guiLayout.AddLayoutX();
                        guiChildLayout.AddSpace(IndentAmount);

                        GUIPanel   guiContentPanel  = guiChildLayout.AddPanel();
                        GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX();
                        guiIndentLayoutX.AddSpace(IndentAmount);
                        GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();
                        guiIndentLayoutY.AddSpace(IndentAmount);
                        GUILayoutY guiContentLayout = guiIndentLayoutY.AddLayoutY();
                        guiIndentLayoutY.AddSpace(IndentAmount);
                        guiIndentLayoutX.AddSpace(IndentAmount);
                        guiChildLayout.AddSpace(IndentAmount);

                        short  backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
                        string bgPanelStyle    = depth % 2 == 0
                           ? EditorStylesInternal.InspectorContentBgAlternate
                           : EditorStylesInternal.InspectorContentBg;
                        GUIPanel   backgroundPanel    = guiContentPanel.AddPanel(backgroundDepth);
                        GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                        backgroundPanel.AddElement(inspectorContentBg);

                        int currentIndex = 0;
                        foreach (var field in fields)
                        {
                            if (!field.Flags.HasFlag(SerializableFieldAttributes.Inspectable))
                            {
                                continue;
                            }

                            string childPath = path + "/" + field.Name;

                            InspectableField inspectable = CreateInspectable(parent, field.Name, childPath,
                                                                             currentIndex, depth + 1, new InspectableFieldLayout(guiContentLayout), field.GetProperty(), InspectableFieldStyle.Create(field));

                            children.Add(inspectable);
                            currentIndex += inspectable.GetNumLayoutElements();
                        }
                    }
                }
                else
                {
                    guiChildLayout = null;
                }
            };

            if (state == State.None)
            {
                if (propertyValue != null)
                {
                    BuildFilledGUI();
                    state = State.Filled;
                }
                else
                {
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
            else if (state == State.Empty)
            {
                if (propertyValue != null)
                {
                    guiInternalTitleLayout.Destroy();
                    guiCreateBtn = null;

                    BuildFilledGUI();
                    state = State.Filled;
                }
            }
            else if (state == State.Filled)
            {
                foreach (var child in children)
                {
                    child.Destroy();
                }

                children.Clear();
                guiInternalTitleLayout.Destroy();
                guiCreateBtn = null;

                if (guiChildLayout != null)
                {
                    guiChildLayout.Destroy();
                    guiChildLayout = null;
                }

                if (propertyValue == null)
                {
                    BuildEmptyGUI();
                    state = State.Empty;
                }
                else
                {
                    BuildFilledGUI();
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Rebuilds the GUI object header if needed.
        /// </summary>
        /// <param name="layoutIndex">Index at which to insert the GUI elements.</param>
        protected void BuildGUI(int layoutIndex)
        {
            Action BuildEmptyGUI = () =>
            {
                if (isInline)
                {
                    return;
                }

                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                guiInternalTitleLayout.AddElement(new GUILabel(title));
                guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100)));

                if (!property.IsValueType)
                {
                    GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create),
                                                           new LocEdString("Create"));
                    guiCreateBtn          = new GUIButton(createIcon, GUIOption.FixedWidth(30));
                    guiCreateBtn.OnClick += OnCreateButtonClicked;
                    guiInternalTitleLayout.AddElement(guiCreateBtn);
                }
            };

            Action BuildFilledGUI = () =>
            {
                if (!isInline)
                {
                    guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                    GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout);
                    guiFoldout.Value           = isExpanded;
                    guiFoldout.AcceptsKeyFocus = false;
                    guiFoldout.OnToggled      += OnFoldoutToggled;
                    guiInternalTitleLayout.AddElement(guiFoldout);

                    if (!property.IsValueType && (style == null || !style.StyleFlags.HasFlag(InspectableFieldStyleFlags.NotNull)))
                    {
                        GUIContent clearIcon = new GUIContent(
                            EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear),
                            new LocEdString("Clear"));
                        GUIButton clearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(20));
                        clearBtn.OnClick += OnClearButtonClicked;
                        guiInternalTitleLayout.AddElement(clearBtn);
                    }
                }

                if (isExpanded || isInline)
                {
                    SerializableObject  serializableObject = property.GetObject();
                    SerializableField[] fields             = serializableObject.Fields;

                    if (fields.Length > 0)
                    {
                        GUILayoutY guiContentLayout;
                        if (!isInline)
                        {
                            guiChildLayout = guiLayout.AddLayoutX();
                            guiChildLayout.AddSpace(IndentAmount);

                            GUIPanel   guiContentPanel  = guiChildLayout.AddPanel();
                            GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX();
                            guiIndentLayoutX.AddSpace(IndentAmount);
                            GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();
                            guiIndentLayoutY.AddSpace(IndentAmount);
                            guiContentLayout = guiIndentLayoutY.AddLayoutY();
                            guiIndentLayoutY.AddSpace(IndentAmount);
                            guiIndentLayoutX.AddSpace(IndentAmount);
                            guiChildLayout.AddSpace(IndentAmount);

                            short  backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
                            string bgPanelStyle    = depth % 2 == 0
                                ? EditorStylesInternal.InspectorContentBgAlternate
                                : EditorStylesInternal.InspectorContentBg;
                            GUIPanel   backgroundPanel    = guiContentPanel.AddPanel(backgroundDepth);
                            GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                            backgroundPanel.AddElement(inspectorContentBg);
                        }
                        else
                        {
                            guiContentLayout = guiLayout;
                        }

                        drawer = new InspectorFieldDrawer(context, guiContentLayout, path, depth + 1);
                        drawer.AddDefault(serializableObject);

                        if (!active)
                        {
                            foreach (var field in drawer.Fields)
                            {
                                field.Active = false;
                            }
                        }
                    }
                }
                else
                {
                    guiChildLayout = null;
                }
            };

            if (state == State.None)
            {
                if (propertyValue != null)
                {
                    BuildFilledGUI();
                    state = State.Filled;
                }
                else
                {
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
            else if (state == State.Empty)
            {
                if (propertyValue != null)
                {
                    guiInternalTitleLayout?.Destroy();
                    guiInternalTitleLayout = null;
                    guiCreateBtn           = null;

                    BuildFilledGUI();
                    state = State.Filled;
                }
            }
            else if (state == State.Filled)
            {
                drawer?.Clear();

                guiInternalTitleLayout?.Destroy();
                guiInternalTitleLayout = null;
                guiCreateBtn           = null;

                if (guiChildLayout != null)
                {
                    guiChildLayout.Destroy();
                    guiChildLayout = null;
                }

                if (propertyValue == null)
                {
                    BuildEmptyGUI();
                    state = State.Empty;
                }
                else
                {
                    BuildFilledGUI();
                }
            }
        }
Exemple #5
0
        private void OnInitialize()
        {
            GUILayoutX splitLayout        = GUI.AddLayoutX();
            GUIPanel   platformPanel      = splitLayout.AddPanel();
            GUIPanel   platformForeground = platformPanel.AddPanel();
            GUILayoutY platformLayout     = platformForeground.AddLayoutY();
            GUIPanel   platformBackground = platformPanel.AddPanel(1);
            GUITexture background         = new GUITexture(Builtin.WhiteTexture);

            background.SetTint(PLATFORM_BG_COLOR);

            splitLayout.AddSpace(5);
            GUILayoutY optionsLayout = splitLayout.AddLayoutY();

            GUILabel platformsLabel = new GUILabel(new LocEdString("Platforms"), EditorStyles.LabelCentered);

            platformLayout.AddSpace(5);
            platformLayout.AddElement(platformsLabel);
            platformLayout.AddSpace(5);

            GUIToggleGroup platformToggleGroup = new GUIToggleGroup();

            PlatformType[] availablePlatforms = BuildManager.AvailablePlatforms;
            platformButtons = new GUIToggle[availablePlatforms.Length];
            for (int i = 0; i < availablePlatforms.Length; i++)
            {
                PlatformType currentPlatform = availablePlatforms[i];
                bool         isActive        = currentPlatform == BuildManager.ActivePlatform;

                string platformName = Enum.GetName(typeof(PlatformType), currentPlatform);
                if (isActive)
                {
                    platformName += " (Active)";
                }

                GUIToggle platformToggle = new GUIToggle(new LocEdString(platformName), platformToggleGroup, EditorStyles.Button);
                platformToggle.OnToggled += x => OnSelectedPlatformChanged(currentPlatform, x);
                platformLayout.AddElement(platformToggle);

                platformButtons[i] = platformToggle;

                if (isActive)
                {
                    platformToggle.Value = true;
                    selectedPlatform     = currentPlatform;
                }
            }

            platformLayout.AddFlexibleSpace();

            GUIButton changePlatformBtn = new GUIButton(new LocEdString("Set active"));

            platformLayout.AddElement(changePlatformBtn);
            changePlatformBtn.OnClick += ChangeActivePlatform;

            platformBackground.AddElement(background);

            optionsScrollArea = new GUIScrollArea();
            optionsLayout.AddElement(optionsScrollArea);

            GUIButton buildButton = new GUIButton(new LocEdString("Build"));

            optionsLayout.AddFlexibleSpace();
            optionsLayout.AddElement(buildButton);

            buildButton.OnClick += TryStartBuild;

            BuildPlatformOptionsGUI();
        }
Exemple #6
0
        /// <summary>
        /// Creates inspectable fields all the fields/properties of the specified object.
        /// </summary>
        /// <param name="obj">Object whose fields the GUI will be drawn for.</param>
        /// <param name="parent">Parent Inspector to draw in.</param>
        /// <param name="path">Full path to the field this provided object was retrieved from.</param>
        /// <param name="depth">
        /// Determines how deep within the inspector nesting hierarchy is this objects. Some fields may contain other
        /// fields, in which case you should increase this value by one.
        /// </param>
        /// <param name="layout">Parent layout that all the field GUI elements will be added to.</param>
        /// <param name="overrideCallback">
        /// Optional callback that allows you to override the look of individual fields in the object. If non-null the
        /// callback will be called with information about every field in the provided object. If the callback returns
        /// non-null that inspectable field will be used for drawing the GUI, otherwise the default inspector field type
        /// will be used.
        /// </param>
        public static List <InspectableField> CreateFields(SerializableObject obj, Inspector parent, string path,
                                                           int depth, GUILayoutY layout, FieldOverrideCallback overrideCallback = null)
        {
            // Retrieve fields and sort by order
            SerializableField[] fields = obj.Fields;
            Array.Sort(fields,
                       (x, y) =>
            {
                int orderX = x.Flags.HasFlag(SerializableFieldAttributes.Order) ? x.Style.Order : 0;
                int orderY = y.Flags.HasFlag(SerializableFieldAttributes.Order) ? y.Style.Order : 0;

                return(orderX.CompareTo(orderY));
            });

            // Generate per-field GUI while grouping by category
            Dictionary <string, Tuple <int, GUILayoutY> > categories = new Dictionary <string, Tuple <int, GUILayoutY> >();

            int rootIndex = 0;
            List <InspectableField> inspectableFields = new List <InspectableField>();

            foreach (var field in fields)
            {
                if (!field.Flags.HasFlag(SerializableFieldAttributes.Inspectable))
                {
                    continue;
                }

                string category = null;
                if (field.Flags.HasFlag(SerializableFieldAttributes.Category))
                {
                    category = field.Style.CategoryName;
                }

                Tuple <int, GUILayoutY> categoryInfo = null;
                if (!string.IsNullOrEmpty(category))
                {
                    if (!categories.TryGetValue(category, out categoryInfo))
                    {
                        InspectableFieldLayout fieldLayout        = new InspectableFieldLayout(layout);
                        GUILayoutY             categoryRootLayout = fieldLayout.AddLayoutY(rootIndex);
                        GUILayoutX             guiTitleLayout     = categoryRootLayout.AddLayoutX();

                        bool isExpanded = parent.Persistent.GetBool(path + "/[" + category + "]_Expanded");

                        GUIToggle guiFoldout = new GUIToggle(category, EditorStyles.Foldout);
                        guiFoldout.Value           = isExpanded;
                        guiFoldout.AcceptsKeyFocus = false;
                        guiFoldout.OnToggled      += x =>
                        {
                            parent.Persistent.SetBool(path + "/[" + category + "]_Expanded", x);
                        };
                        guiTitleLayout.AddElement(guiFoldout);

                        GUILayoutX categoryContentLayout = categoryRootLayout.AddLayoutX();
                        categoryContentLayout.AddSpace(IndentAmount);

                        GUIPanel   guiContentPanel  = categoryContentLayout.AddPanel();
                        GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX();
                        guiIndentLayoutX.AddSpace(IndentAmount);
                        GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();
                        guiIndentLayoutY.AddSpace(IndentAmount);
                        GUILayoutY categoryLayout = guiIndentLayoutY.AddLayoutY();
                        guiIndentLayoutY.AddSpace(IndentAmount);
                        guiIndentLayoutX.AddSpace(IndentAmount);
                        categoryContentLayout.AddSpace(IndentAmount);

                        short  backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
                        string bgPanelStyle    = depth % 2 == 0
                            ? EditorStylesInternal.InspectorContentBgAlternate
                            : EditorStylesInternal.InspectorContentBg;
                        GUIPanel   backgroundPanel    = guiContentPanel.AddPanel(backgroundDepth);
                        GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                        backgroundPanel.AddElement(inspectorContentBg);

                        categories[category] = new Tuple <int, GUILayoutY>(0, categoryLayout);
                        rootIndex++;
                    }
                }

                int        currentIndex;
                GUILayoutY parentLayout;
                if (categoryInfo != null)
                {
                    currentIndex = categoryInfo.Item1;
                    parentLayout = categoryInfo.Item2;
                }
                else
                {
                    currentIndex = rootIndex;
                    parentLayout = layout;
                }

                string fieldName = field.Name;
                string childPath = string.IsNullOrEmpty(path) ? fieldName : path + "/" + fieldName;

                InspectableField inspectableField = null;

                if (overrideCallback != null)
                {
                    inspectableField = overrideCallback(field, parent, path, new InspectableFieldLayout(parentLayout),
                                                        currentIndex, depth);
                }

                if (inspectableField == null)
                {
                    inspectableField = CreateField(parent, fieldName, childPath,
                                                   currentIndex, depth, new InspectableFieldLayout(parentLayout), field.GetProperty(),
                                                   InspectableFieldStyle.Create(field));
                }

                inspectableFields.Add(inspectableField);
                currentIndex += inspectableField.GetNumLayoutElements();

                if (categoryInfo != null)
                {
                    categories[category] = new Tuple <int, GUILayoutY>(currentIndex, parentLayout);
                }
                else
                {
                    rootIndex = currentIndex;
                }
            }

            return(inspectableFields);
        }
        /// <summary>
        /// Rebuilds the GUI object header if needed. 
        /// </summary>
        /// <param name="layoutIndex">Index at which to insert the GUI elements.</param>
        protected void BuildGUI(int layoutIndex)
        {
            Action BuildEmptyGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                guiInternalTitleLayout.AddElement(new GUILabel(title));
                guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100)));

                if (!property.IsValueType)
                {
                    GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create),
                        new LocEdString("Create"));
                    GUIButton createBtn = new GUIButton(createIcon, GUIOption.FixedWidth(30));
                    createBtn.OnClick += OnCreateButtonClicked;
                    guiInternalTitleLayout.AddElement(createBtn);
                }
            };

               Action BuildFilledGUI = () =>
               {
               guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

               GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout);
               guiFoldout.Value = isExpanded;
               guiFoldout.OnToggled += OnFoldoutToggled;
               guiInternalTitleLayout.AddElement(guiFoldout);

               GUIContent clearIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear),
                   new LocEdString("Clear"));
               GUIButton clearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(20));
               clearBtn.OnClick += OnClearButtonClicked;
               guiInternalTitleLayout.AddElement(clearBtn);

               if (isExpanded)
               {
                   SerializableObject serializableObject = property.GetObject();
                   SerializableField[] fields = serializableObject.Fields;

                   if (fields.Length > 0)
                   {
                       guiChildLayout = guiLayout.AddLayoutX();
                       guiChildLayout.AddSpace(IndentAmount);

                       GUIPanel guiContentPanel = guiChildLayout.AddPanel();
                       GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX();
                       guiIndentLayoutX.AddSpace(IndentAmount);
                       GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();
                       guiIndentLayoutY.AddSpace(IndentAmount);
                       GUILayoutY guiContentLayout = guiIndentLayoutY.AddLayoutY();
                       guiIndentLayoutY.AddSpace(IndentAmount);
                       guiIndentLayoutX.AddSpace(IndentAmount);
                       guiChildLayout.AddSpace(IndentAmount);

                       short backgroundDepth = (short) (Inspector.START_BACKGROUND_DEPTH - depth - 1);
                       string bgPanelStyle = depth%2 == 0
                           ? EditorStyles.InspectorContentBgAlternate
                           : EditorStyles.InspectorContentBg;
                       GUIPanel backgroundPanel = guiContentPanel.AddPanel(backgroundDepth);
                       GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                       backgroundPanel.AddElement(inspectorContentBg);

                       int currentIndex = 0;
                       foreach (var field in fields)
                       {
                           if (!field.Inspectable)
                               continue;

                           string childPath = path + "/" + field.Name;

                           InspectableField inspectable = CreateInspectable(parent, field.Name, childPath,
                               currentIndex, depth + 1, new InspectableFieldLayout(guiContentLayout), field.GetProperty());

                           children.Add(inspectable);
                           currentIndex += inspectable.GetNumLayoutElements();
                       }
                   }
               }
               else
                   guiChildLayout = null;
               };

               if (state == State.None)
               {
               if (propertyValue != null)
               {
                   BuildFilledGUI();
                   state = State.Filled;
               }
               else
               {
                   BuildEmptyGUI();

                   state = State.Empty;
               }
               }
               else if (state == State.Empty)
               {
               if (propertyValue != null)
               {
                   guiInternalTitleLayout.Destroy();
                   BuildFilledGUI();
                   state = State.Filled;
               }
               }
               else if (state == State.Filled)
               {
               foreach (var child in children)
                   child.Destroy();

               children.Clear();
               guiInternalTitleLayout.Destroy();

               if (guiChildLayout != null)
               {
                   guiChildLayout.Destroy();
                   guiChildLayout = null;
               }

               if (propertyValue == null)
               {
                   BuildEmptyGUI();
                   state = State.Empty;
               }
               else
               {
                   BuildFilledGUI();
               }
               }
        }