Пример #1
0
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();

            GUILayoutExt.DrawComponentHeader(this.serializedObject, "M", () => {
                GUILayoutExt.DrawComponentHeaderItem("State", GUILayoutExt.GetPropertyToString(this.objectState));
            }, new Color(1f, 0.6f, 1f, 0.4f));

            GUILayout.Space(5f);

            var scroll = this.tabScrollPosition;

            this.selectedTab = GUILayoutExt.DrawTabs(
                this.selectedTab,
                ref scroll,
                new GUITab("Basic", () => {
                GUILayoutExt.DrawHeader("Main");
                EditorGUILayout.PropertyField(this.hiddenByDefault);
                EditorGUILayout.PropertyField(this.animationParameters);
                EditorGUILayout.PropertyField(this.subObjects);

                GUILayoutExt.DrawHeader("Performance Options");
                EditorGUILayout.PropertyField(this.createPool);
            }),
                new GUITab("Advanced", () => {
                GUILayoutExt.DrawHeader("Render Behaviour");
                EditorGUILayout.PropertyField(this.renderBehaviourOnHidden);

                GUILayoutExt.DrawHeader("Animation");
                EditorGUILayout.PropertyField(this.animationParameters);

                GUILayoutExt.DrawHeader("Graph");
                EditorGUILayout.PropertyField(this.allowRegisterInRoot);
                EditorGUILayout.PropertyField(this.autoRegisterSubObjects);
                EditorGUILayout.PropertyField(this.hiddenByDefault);
                EditorGUILayout.PropertyField(this.subObjects);

                GUILayoutExt.DrawHeader("Performance Options");
                EditorGUILayout.PropertyField(this.createPool);
            })
                );
            this.tabScrollPosition = scroll;

            GUILayout.Space(10f);

            var iter = this.serializedObject.GetIterator();

            iter.NextVisible(true);
            do
            {
                if (EditorHelpers.IsFieldOfTypeBeneath(this.serializedObject.targetObject.GetType(), typeof(WindowModule), iter.propertyPath) == true)
                {
                    EditorGUILayout.PropertyField(iter);
                }
            } while (iter.NextVisible(false) == true);

            this.serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();

            GUILayoutExt.DrawComponentHeader(this.serializedObject, "S", () => {
                GUILayoutExt.DrawComponentHeaderItem("State", GUILayoutExt.GetPropertyToString(this.objectState));
                GUILayoutExt.DrawComponentHeaderItem("Focus", GUILayoutExt.GetPropertyToString(this.focusState));

                GUILayout.FlexibleSpace();
            }, new Color(0f, 0.6f, 0f, 0.4f));

            GUILayout.Space(5f);

            var scroll = this.tabScrollPosition;

            this.selectedTab = GUILayoutExt.DrawTabs(
                this.selectedTab,
                ref scroll,
                new GUITab("Preferences", () => {
                GUILayoutExt.DrawProperty(this.preferences);
                EditorGUILayout.PropertyField(this.createPool);
            }),
                new GUITab("Modules (" + this.listModules.count.ToString() + ")", () => {
                this.listModules.DoLayoutList();
            }),
                new GUITab("Layouts", () => {
                EditorGUILayout.PropertyField(this.layouts);
            }),
                new GUITab("Audio", () => {
                GUILayoutExt.DrawHeader("Events");
                var enterChildren = true;
                var prop          = this.audioEvents.Copy();
                var depth         = prop.depth + 1;
                while (prop.NextVisible(enterChildren) == true && prop.depth >= depth)
                {
                    EditorGUILayout.PropertyField(prop, true);
                    enterChildren = false;
                }
            })
                );
            this.tabScrollPosition = scroll;

            GUILayout.Space(10f);

            var iter = this.serializedObject.GetIterator();

            iter.NextVisible(true);
            do
            {
                if (EditorHelpers.IsFieldOfTypeBeneath(this.serializedObject.targetObject.GetType(), typeof(UnityEngine.UI.Windows.WindowTypes.LayoutWindowType), iter.propertyPath) == true)
                {
                    EditorGUILayout.PropertyField(iter);
                }
            } while (iter.NextVisible(false) == true);

            this.serializedObject.ApplyModifiedProperties();
        }
Пример #3
0
        public static void DrawLayout(int selectedIndexAspect, int selectedIndexInner, int selectedType, System.Action <int, int, int> onSet, ref Vector2 tabsScrollPosition, WindowLayout windowLayout, Rect r, UnityEngine.UI.Windows.WindowTypes.LayoutWindowType drawComponents)
        {
            var offset = 20f;
            var aspect = 4f / 3f;

            DeviceInfo.OrientationData orienData  = default;
            DeviceInfo.ScreenData      screenData = default;
            if (Selection.objects.Length == 1)
            {
                if (WindowLayoutUtilities.loadedDevices.Count == 0)
                {
                    var devices             = new List <DeviceInfo>();
                    var deviceDirectoryPath = System.IO.Path.GetFullPath(System.IO.Path.Combine("Packages", "com.unity.device-simulator", ".DeviceDefinitions"));
                    if (UnityEngine.Windows.Directory.Exists(deviceDirectoryPath) == true)
                    {
                        var deviceDirectory   = new System.IO.DirectoryInfo(deviceDirectoryPath);
                        var deviceDefinitions = deviceDirectory.GetFiles("*.device.json");
                        foreach (var deviceDefinition in deviceDefinitions)
                        {
                            string deviceFileText;
                            using (System.IO.StreamReader sr = deviceDefinition.OpenText()) {
                                deviceFileText = sr.ReadToEnd();
                            }

                            var deviceInfo = JsonUtility.FromJson <DeviceInfo>(deviceFileText);
                            devices.Add(deviceInfo);
                        }
                    }

                    WindowLayoutUtilities.loadedDevices = devices;
                }

                GUILayout.BeginHorizontal();

                var selectedName = "Default Aspects";
                if (selectedType == 1)
                {
                    var dInfo = WindowLayoutUtilities.loadedDevices[selectedIndexAspect];
                    selectedName = dInfo.friendlyName;
                }

                if (WindowLayoutUtilities.loadedDevices.Count > 0)
                {
                    if (GUILayout.Button(selectedName, EditorStyles.toolbarDropDown) == true)
                    {
                        var popup = new Popup(title: "Devices", size: new Vector2(200f, 250f));
                        popup.autoClose  = true;
                        popup.autoHeight = false;
                        popup.Item("Default Aspects", () => { onSet.Invoke(0, 0, 0); }, order: -1);

                        for (var i = 0; i < WindowLayoutUtilities.loadedDevices.Count; ++i)
                        {
                            var idx        = i;
                            var deviceInfo = WindowLayoutUtilities.loadedDevices[i];
                            var screens    = deviceInfo.Screens ?? deviceInfo.screens;
                            if (screens != null)
                            {
                                popup.Item(deviceInfo.friendlyName, () => { onSet.Invoke(1, idx, 0); }, order: idx);
                            }
                        }

                        popup.Show();
                    }
                }

                if (selectedType == 0)
                {
                    var items = new Item[] {
                        new Item()
                        {
                            name = "4:3", value = 4f / 3f
                        },
                        new Item()
                        {
                            name = "16:9", value = 16f / 9f
                        },
                        new Item()
                        {
                            name = "16:10", value = 16f / 10f
                        },
                        new Item()
                        {
                            name = "5:4", value = 5f / 4f
                        },
                        new Item()
                        {
                            name = "2:1", value = 2f / 1f
                        },

                        new Item()
                        {
                            name = "3:4", value = 3f / 4f
                        },
                        new Item()
                        {
                            name = "9:16", value = 9f / 16f
                        },
                        new Item()
                        {
                            name = "10:16", value = 10f / 16f
                        },
                        new Item()
                        {
                            name = "4:5", value = 4f / 5f
                        },
                        new Item()
                        {
                            name = "1:2", value = 1f / 2f
                        },
                    };

                    var tabs = items.Select(x => new GUITab(x.name, null)).ToArray();
                    selectedIndexAspect = GUILayoutExt.DrawTabs(selectedIndexAspect, ref tabsScrollPosition, tabs);
                    aspect = items[selectedIndexAspect].value;
                }
                else if (selectedType == 1)
                {
                    var deviceInfo = WindowLayoutUtilities.loadedDevices[selectedIndexAspect];
                    var screens    = deviceInfo.Screens ?? deviceInfo.screens;
                    var items      = new Item[4];
                    for (int i = 0; i < screens.Length; ++i)
                    {
                        var oris = screens[i].orientations;
                        for (int j = 0; j < oris.Length; ++j)
                        {
                            if (oris[j].orientation == ScreenOrientation.LandscapeRight)
                            {
                                var hData = screens[i];
                                var w     = hData.width;
                                hData.width  = hData.height;
                                hData.height = w;

                                items[0] = new Item()
                                {
                                    name       = "Landscape Right",
                                    value      = hData.width / (float)hData.height,
                                    data       = oris[j],
                                    screenData = hData
                                };
                            }
                            else if (oris[j].orientation == ScreenOrientation.Landscape ||
                                     oris[j].orientation == ScreenOrientation.LandscapeLeft)
                            {
                                var hData = screens[i];
                                var w     = hData.width;
                                hData.width  = hData.height;
                                hData.height = w;

                                items[1] = new Item()
                                {
                                    name       = "Landscape Left",
                                    value      = hData.width / (float)hData.height,
                                    data       = oris[j],
                                    screenData = hData
                                };
                            }
                            else if (oris[j].orientation == ScreenOrientation.Portrait)
                            {
                                items[2] = new Item()
                                {
                                    name       = "Portrait Up",
                                    value      = screens[i].width / (float)screens[i].height,
                                    data       = oris[j],
                                    screenData = screens[i]
                                };
                            }
                            else if (oris[j].orientation == ScreenOrientation.PortraitUpsideDown)
                            {
                                items[3] = new Item()
                                {
                                    name       = "Portrait Down",
                                    value      = screens[i].width / (float)screens[i].height,
                                    data       = oris[j],
                                    screenData = screens[i]
                                };
                            }
                        }
                    }

                    var tabs = items.Select(x => new GUITab(x.name, null)).ToArray();
                    selectedIndexInner = GUILayoutExt.DrawTabs(selectedIndexInner, ref tabsScrollPosition, tabs);
                    aspect             = items[selectedIndexInner].value;
                    orienData          = items[selectedIndexInner].data;
                    screenData         = items[selectedIndexInner].screenData;
                }

                GUILayout.EndHorizontal();
            }
            else
            {
                offset = 0f;
            }

            var used = new HashSet <WindowLayout>();

            WindowLayoutUtilities.DrawLayout(aspect, windowLayout, r, offset, used, screenData, orienData, drawComponents);

            onSet.Invoke(selectedType, selectedIndexAspect, selectedIndexInner);
        }
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();

            GUILayoutExt.DrawComponentHeader(this.serializedObject, "L", () => {
                GUILayoutExt.DrawComponentHeaderItem("State", GUILayoutExt.GetPropertyToString(this.objectState));
            }, new Color(1f, 0.6f, 0f, 0.4f));

            GUILayout.Space(5f);

            var scroll = this.tabScrollPosition;

            this.selectedTab = GUILayoutExt.DrawTabs(
                this.selectedTab,
                ref scroll,
                new GUITab("Basic", () => {
                GUILayoutExt.DrawHeader("Main");
                EditorGUILayout.PropertyField(this.hiddenByDefault);
                EditorGUILayout.PropertyField(this.animationParameters);
                EditorGUILayout.PropertyField(this.subObjects);

                GUILayoutExt.DrawHeader("Performance Options");
                EditorGUILayout.PropertyField(this.createPool);
            }),
                new GUITab("Advanced", () => {
                GUILayoutExt.DrawHeader("Render Behaviour");
                EditorGUILayout.PropertyField(this.renderBehaviourOnHidden);

                GUILayoutExt.DrawHeader("Animation");
                EditorGUILayout.PropertyField(this.animationParameters);

                GUILayoutExt.DrawHeader("Graph");
                EditorGUILayout.PropertyField(this.allowRegisterInRoot);
                EditorGUILayout.PropertyField(this.autoRegisterSubObjects);
                EditorGUILayout.PropertyField(this.hiddenByDefault);
                EditorGUILayout.PropertyField(this.subObjects);

                GUILayoutExt.DrawHeader("Performance Options");
                EditorGUILayout.PropertyField(this.createPool);
            })
                );
            this.tabScrollPosition = scroll;

            GUILayout.Space(10f);

            EditorGUILayout.PropertyField(this.useSafeZone);
            if (this.useSafeZone.boolValue == true)
            {
                GUILayoutExt.Box(2f, 2f, () => {
                    EditorGUILayout.PropertyField(this.safeZone);
                    if (this.safeZone.objectReferenceValue == null && this.targets.Length == 1)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Generate", GUILayout.Width(80f), GUILayout.Height(30f)) == true)
                        {
                            var obj = this.target as Component;
                            if (PrefabUtility.IsPartOfAnyPrefab(obj) == true)
                            {
                                var path = AssetDatabase.GetAssetPath(obj.gameObject);
                                using (var edit = new EditPrefabAssetScope(path)) {
                                    EditorHelpers.AddSafeZone(edit.prefabRoot.transform);
                                }
                            }
                            else
                            {
                                var root = obj.gameObject;
                                EditorHelpers.AddSafeZone(root.transform);
                            }
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                });
            }

            GUILayout.Space(10f);

            var iter = this.serializedObject.GetIterator();

            iter.NextVisible(true);
            do
            {
                if (EditorHelpers.IsFieldOfTypeBeneath(this.serializedObject.targetObject.GetType(), typeof(WindowLayout), iter.propertyPath) == true)
                {
                    EditorGUILayout.PropertyField(iter);
                }
            } while (iter.NextVisible(false) == true);

            this.serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();

            GUILayoutExt.DrawComponentHeader(this.serializedObject, "UI", () => {
                GUILayout.Label("Window System", GUILayout.Height(36f));
            }, new Color(0.3f, 0.4f, 0.6f, 0.4f));

            GUILayout.Space(5f);

            var scroll = this.tabScrollPosition;

            this.selectedTab = GUILayoutExt.DrawTabs(
                this.selectedTab,
                ref scroll,
                new GUITab("Start Up", () => {
                EditorGUILayout.PropertyField(this.emulatePlatform);
                EditorGUILayout.PropertyField(this.emulateRuntimePlatform);

                GUILayout.Space(10f);

                EditorGUILayout.PropertyField(this.showRootOnStart);
                EditorGUILayout.PropertyField(this.rootScreen);

                GUILayout.Space(10f);

                EditorGUILayout.PropertyField(this.settings);
            }),
                new GUITab("Modules", () => {
                EditorGUILayout.PropertyField(this.breadcrumbs);
                EditorGUILayout.PropertyField(this.events);
                EditorGUILayout.PropertyField(this.resources);
                EditorGUILayout.PropertyField(this.pools);
                EditorGUILayout.PropertyField(this.tweener);
            }),
                new GUITab("Windows", () => {
                var count = this.registeredPrefabs.arraySize;
                EditorGUILayout.PropertyField(this.registeredPrefabs, new GUIContent("Registered Prefabs (" + count + ")"));

                GUILayout.Space(10f);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Collect prefabs", GUILayout.Width(200f), GUILayout.Height(30f)) == true)
                {
                    var list        = new List <WindowBase>();
                    var gameObjects = AssetDatabase.FindAssets("t:GameObject");
                    foreach (var guid in gameObjects)
                    {
                        var path  = AssetDatabase.GUIDToAssetPath(guid);
                        var asset = AssetDatabase.LoadAssetAtPath <GameObject>(path);
                        var win   = asset.GetComponent <WindowBase>();
                        if (win != null)
                        {
                            list.Add(win);
                        }
                    }

                    this.registeredPrefabs.ClearArray();
                    this.registeredPrefabs.arraySize = list.Count;
                    for (int i = 0; i < list.Count; ++i)
                    {
                        this.registeredPrefabs.GetArrayElementAtIndex(i).objectReferenceValue = list[i];
                    }
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            })
                );
            this.tabScrollPosition = scroll;

            /*
             * GUILayout.Space(10f);
             *
             * var iter = this.serializedObject.GetIterator();
             * iter.NextVisible(true);
             * do {
             *
             *  if (EditorHelpers.IsFieldOfType(typeof(WindowSystem), iter.propertyPath) == true) {
             *
             *      EditorGUILayout.PropertyField(iter);
             *
             *  }
             *
             * } while (iter.NextVisible(false) == true);*/

            this.serializedObject.ApplyModifiedProperties();
        }
Пример #6
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var evenStyle = new GUIStyle(GUIStyle.none);

            evenStyle.normal.background = Texture2D.whiteTexture;
            var tagStyle = new GUIStyle(EditorStyles.label);

            tagStyle.alignment = TextAnchor.MiddleRight;
            var innerLayoutStyle = new GUIStyle(EditorStyles.miniLabel);

            innerLayoutStyle.alignment     = TextAnchor.UpperLeft;
            innerLayoutStyle.stretchHeight = false;

            var items = property.FindPropertyRelative("items");

            if (items.arraySize == 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Add Layout", GUILayout.Height(30f), GUILayout.Width(120f)) == true)
                {
                    ++items.arraySize;
                    this.selectedTab = 0;
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.Space(20f);
                return;
            }

            var arr = new GUITab[items.arraySize + 1];

            this.selectedTab = Mathf.Clamp(this.selectedTab, 0, arr.Length - 2);
            var i = 0;

            for (i = 0; i < items.arraySize; ++i)
            {
                var idx     = i;
                var prop    = items.GetArrayElementAtIndex(i);
                var objRef  = prop.FindPropertyRelative("windowLayout").objectReferenceValue;
                var caption = (objRef != null ? EditorHelpers.StringToCaption(objRef.name) : "Layout (Empty)");
                arr[i] = new GUITab(caption, () => {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Remove", GUILayout.Width(60f)) == true)
                        {
                            if (EditorUtility.DisplayDialog("Delete Layout Reference", "Are you sure?", "Yes", "No") == true)
                            {
                                items.DeleteArrayElementAtIndex(idx);
                                return;
                            }
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (idx > 0)
                    {
                        GUILayout.Space(6f);

                        EditorGUI.BeginChangeCheck();
                        var targets = prop.FindPropertyRelative("targets");
                        EditorGUILayout.PropertyField(targets);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            EditorHelpers.SetDirtyAndValidate(property);
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("This is default layout. Target Filter couldn't been attach here.", MessageType.Info);
                    }

                    GUILayout.Space(6f);

                    EditorGUI.BeginChangeCheck();
                    var windowLayout = prop.FindPropertyRelative("windowLayout");
                    EditorGUILayout.PropertyField(windowLayout);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        EditorHelpers.SetDirtyAndValidate(property);
                    }

                    var layout = windowLayout.objectReferenceValue as WindowLayout;
                    if (layout == null)
                    {
                        return;
                    }

                    EditorGUI.BeginChangeCheck();
                    var layoutPreferences = prop.FindPropertyRelative("layoutPreferences");
                    EditorGUILayout.PropertyField(layoutPreferences);
                    if (layoutPreferences.objectReferenceValue == null)
                    {
                        EditorGUILayout.HelpBox("Layout Preferences are CanvasScaler override parameters. It's highly recommended to use override here.", MessageType.Info);
                    }

                    if (layoutPreferences.objectReferenceValue is WindowLayoutPreferences windowLayoutPreferences)
                    {
                        windowLayoutPreferences.Apply(layout.canvasScaler);

                        try {
                            EditorGUI.BeginDisabledGroup(true);
                            var editorCanvasScaler = Editor.CreateEditor(layout.canvasScaler);
                            editorCanvasScaler.OnInspectorGUI();
                            EditorGUI.EndDisabledGroup();
                        } catch (System.Exception) {}
                    }

                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        EditorHelpers.SetDirtyAndValidate(property);
                    }

                    GUILayout.Space(2f);
                    GUILayoutExt.Separator();
                    GUILayout.Space(2f);

                    if (this.list == null)
                    {
                        var componentsProp      = prop.FindPropertyRelative("components");
                        this.list               = new UnityEditorInternal.ReorderableList(property.serializedObject, componentsProp, true, true, false, false);
                        this.list.elementHeight = 40f;
                        this.list.onAddCallback = (rList) => {
                            if (rList.serializedProperty != null)
                            {
                                ++rList.serializedProperty.arraySize;
                                rList.index = rList.serializedProperty.arraySize - 1;
                            }
                        };
                        this.list.drawElementBackgroundCallback = (rect, index, active, focused) => {
                            if (focused == true)
                            {
                                GUILayoutExt.DrawRect(rect, new Color(0.1f, 0.4f, 0.7f, 1f));
                            }
                            else
                            {
                                GUILayoutExt.DrawRect(rect, new Color(1f, 1f, 1f, index % 2 == 0 ? 0.05f : 0f));
                            }
                        };
                        this.list.drawElementCallback = (rect, index, active, focused) => {
                            //EditorGUI.PropertyField(rect, componentsProp.GetArrayElementAtIndex(index));

                            EditorGUI.BeginChangeCheck();
                            {
                                var captionRect = new Rect(rect.x, rect.y, rect.width, 18f);
                                var tagRect     = captionRect;
                                var layoutRect  = new Rect(tagRect.x + 140f, tagRect.y, tagRect.width, tagRect.height);
                                var objectRect  = new Rect(captionRect.x, captionRect.y + 18f, captionRect.width, captionRect.height);

                                var compProp  = componentsProp.GetArrayElementAtIndex(index);
                                var component = compProp.FindPropertyRelative("component");

                                var localRagId        = compProp.FindPropertyRelative("localTag").intValue;
                                var windowLayoutInner = (WindowLayout)compProp.FindPropertyRelative("windowLayout").objectReferenceValue;
                                string layoutName     = string.Empty;
                                if (windowLayoutInner != null)
                                {
                                    var tagId         = compProp.FindPropertyRelative("tag").intValue;
                                    var layoutElement = windowLayoutInner.GetLayoutElementByTagId(tagId);
                                    if (layoutElement != null)
                                    {
                                        layoutName = layoutElement.name;
                                    }
                                }

                                using (GUILayoutExt.GUIColor(new Color(1f, 1f, 1f, 0.4f))) {
                                    if (windowLayoutInner != null && windowLayoutInner != layout)
                                    {
                                        GUI.Label(layoutRect, "(" + EditorHelpers.StringToCaption(windowLayoutInner.name) + ")", innerLayoutStyle);
                                    }
                                }

                                GUI.Label(captionRect, EditorHelpers.StringToCaption(layoutName), EditorStyles.boldLabel);
                                GUI.Label(tagRect, "Tag: " + localRagId.ToString(), tagStyle);
                                EditorGUI.PropertyField(objectRect, component, new GUIContent(string.Empty));
                            }

                            if (EditorGUI.EndChangeCheck() == true)
                            {
                                EditorHelpers.SetDirtyAndValidate(property);
                            }
                        };
                        this.list.drawHeaderCallback = (rect) => {
                            GUI.Label(rect, "Components");
                            var buttonRect   = rect;
                            var width        = 80f;
                            buttonRect.x     = rect.width - width;
                            buttonRect.width = width;
                            if (GUI.Button(buttonRect, "Refresh") == true)
                            {
                                (componentsProp.serializedObject.targetObject as WindowObject).ValidateEditor();
                            }
                        };
                    }

                    this.list.DoLayoutList();

                    /*
                     * EditorGUI.BeginChangeCheck();
                     * var components = prop.FindPropertyRelative("components");
                     * for (int j = 0; j < components.arraySize; ++j) {
                     *
                     *  var compProp = components.GetArrayElementAtIndex(j);
                     *  var component = compProp.FindPropertyRelative("component");
                     *
                     *  var c = GUI.color;
                     *  GUI.color = new Color(1f, 1f, 1f, 0.1f);
                     *  GUILayout.BeginVertical(j % 2 == 0 ? evenStyle : oddStyle);
                     *  GUI.color = c;
                     *  {
                     *
                     *      GUILayout.Space(4f);
                     *      GUILayout.BeginHorizontal();
                     *      {
                     *          var localRagId = compProp.FindPropertyRelative("localTag").intValue;
                     *          var windowLayoutInner = (WindowLayout)compProp.FindPropertyRelative("windowLayout").objectReferenceValue;
                     *          string layoutName = string.Empty;
                     *          if (windowLayoutInner != null) {
                     *
                     *              var tagId = compProp.FindPropertyRelative("tag").intValue;
                     *              var layoutElement = windowLayoutInner.GetLayoutElementByTagId(tagId);
                     *              if (layoutElement != null) layoutName = layoutElement.name;
                     *
                     *          }
                     *          GUILayout.Label(EditorHelpers.StringToCaption(layoutName), EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
                     *          using (GUILayoutExt.GUIColor(new Color(1f, 1f, 1f, 0.4f))) {
                     *              if (windowLayoutInner != null && windowLayoutInner != layout) GUILayout.Label("(" + EditorHelpers.StringToCaption(windowLayoutInner.name) + ")", innerLayoutStyle, GUILayout.ExpandWidth(false));
                     *          }
                     *
                     *          GUILayout.FlexibleSpace();
                     *          GUILayout.Label("Tag: " + localRagId.ToString(), tagStyle, GUILayout.ExpandWidth(false));
                     *      }
                     *      GUILayout.EndHorizontal();
                     *      EditorGUILayout.PropertyField(component);
                     *
                     *      GUILayout.Space(4f);
                     *      GUILayoutExt.Separator();
                     *
                     *  }
                     *  GUILayout.EndVertical();
                     *
                     * }
                     * if (EditorGUI.EndChangeCheck() == true) {
                     *
                     *  EditorHelpers.SetDirtyAndValidate(property);
                     *
                     * }*/
                });
            }

            arr[i] = new GUITab("+", () => {
            }, 40f);

            var scroll = this.tabScrollPosition;
            var newTab = GUILayoutExt.DrawTabs(
                this.selectedTab,
                ref scroll,
                arr
                );

            this.tabScrollPosition = scroll;

            if (newTab != this.selectedTab)
            {
                if (newTab == i)
                {
                    // Add item
                    ++items.arraySize;
                    this.selectedTab = i;
                }
                else
                {
                    this.selectedTab = newTab;
                }
            }
        }
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();

            GUILayoutExt.DrawComponentHeader(this.serializedObject, "C", () => {
                GUILayoutExt.DrawComponentHeaderItem("State", GUILayoutExt.GetPropertyToString(this.objectState));
            });

            GUILayout.Space(5f);

            var scroll = this.tabScrollPosition;

            this.selectedTab = GUILayoutExt.DrawTabs(
                this.selectedTab,
                ref scroll,
                new GUITab("Basic", () => {
                GUILayoutExt.DrawHeader("Main");
                GUILayoutExt.PropertyField(this.hiddenByDefault, (reg) => reg.hiddenByDefault == true ? reg.hiddenByDefaultDescription : string.Empty);
                EditorGUILayout.PropertyField(this.subObjects);

                GUILayoutExt.DrawHeader("Animations");
                EditorGUILayout.PropertyField(this.animationParameters);

                GUILayoutExt.DrawHeader("Performance Options");
                EditorGUILayout.PropertyField(this.createPool);

                this.DrawCanvas();
            }),
                new GUITab("Advanced", () => {
                GUILayoutExt.DrawHeader("Render Behaviour");
                EditorGUILayout.PropertyField(this.renderBehaviourOnHidden);

                GUILayoutExt.DrawHeader("Animations");
                EditorGUILayout.PropertyField(this.animationParameters);

                GUILayoutExt.DrawHeader("Graph");
                GUILayoutExt.PropertyField(this.allowRegisterInRoot, (reg) => reg.allowRegisterInRoot == true ? reg.allowRegisterInRootDescription : string.Empty);
                EditorGUILayout.PropertyField(this.autoRegisterSubObjects);
                GUILayoutExt.PropertyField(this.hiddenByDefault, (reg) => reg.hiddenByDefault == true ? reg.hiddenByDefaultDescription : string.Empty);
                EditorGUILayout.PropertyField(this.subObjects);

                GUILayoutExt.DrawHeader("Performance Options");
                EditorGUILayout.PropertyField(this.createPool);

                this.DrawCanvas();
            }),
                this.listModules == null ? GUITab.none : new GUITab("Modules (" + this.listModules.count + ")", () => {
                this.listModules.DoLayoutList();
            }),
                new GUITab("Audio", () => {
                GUILayoutExt.DrawHeader("Events");
                var enterChildren = true;
                var prop          = this.audioEvents.Copy();
                var depth         = prop.depth + 1;
                while (prop.NextVisible(enterChildren) == true && prop.depth >= depth)
                {
                    EditorGUILayout.PropertyField(prop, true);
                    enterChildren = false;
                }
            })
                );
            this.tabScrollPosition = scroll;

            GUILayout.Space(10f);

            var iter = this.serializedObject.GetIterator();

            iter.NextVisible(true);
            do
            {
                if (EditorHelpers.IsFieldOfTypeBeneath(this.serializedObject.targetObject.GetType(), typeof(WindowComponent), iter.propertyPath) == true)
                {
                    EditorGUILayout.PropertyField(iter);
                }
            } while (iter.NextVisible(false) == true);

            this.serializedObject.ApplyModifiedProperties();
        }