public override void OnInspectorGUI()
        {
            DungeonFlow data = target as DungeonFlow;

            if (data == null)
                return;

            data.KeyManager = (KeyManager)EditorGUILayout.ObjectField("Key Manager", data.KeyManager, typeof(KeyManager), false);
            EditorUtil.DrawIntRange("Length", data.Length);

            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.HelpBox("The percentage chance that an unconnected but overlapping set of doorways will be connected", MessageType.Info);
            data.DoorwayConnectionChance = EditorGUILayout.Slider("Connection Chance", data.DoorwayConnectionChance, 0, 1);
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (GUILayout.Button("Open Flow Editor"))
                DungeonFlowEditorWindow.Open(data);

            DrawTileInjectionRules(data);

            EditorGUILayout.Space();

            showPropGroups = EditorGUILayout.Foldout(showPropGroups, "Global Props");

            if (showPropGroups)
            {
                int toDeleteIndex = -1;
                GUILayout.BeginVertical("box");

                for (int i = 0; i < data.GlobalPropGroupIDs.Count; i++)
                {
                    EditorGUILayout.BeginVertical("box");

                    EditorGUILayout.BeginHorizontal();
                    data.GlobalPropGroupIDs[i] = EditorGUILayout.IntField("Group ID", data.GlobalPropGroupIDs[i]);

                    if (GUILayout.Button("×", EditorStyles.miniButton, GUILayout.Width(19)))
                        toDeleteIndex = i;

                    EditorGUILayout.EndHorizontal();

                    EditorUtil.DrawIntRange("Count", data.GlobalPropRanges[i]);
                    EditorGUILayout.EndVertical();
                }

                if (toDeleteIndex >= 0)
                {
                    data.GlobalPropGroupIDs.RemoveAt(toDeleteIndex);
                    data.GlobalPropRanges.RemoveAt(toDeleteIndex);
                }

                if (GUILayout.Button("Add New"))
                {
                    data.GlobalPropGroupIDs.Add(0);
                    data.GlobalPropRanges.Add(new IntRange(0, 1));
                }

                EditorGUILayout.EndVertical();
            }

            if (GUI.changed)
                EditorUtility.SetDirty(data);
        }
 public static void Open()
 {
     DungeonFlowEditorWindow.Open(null);
 }
        public override void OnInspectorGUI()
        {
            var data = target as DungeonFlow;

            if (data == null)
            {
                return;
            }

            serializedObject.Update();

            if (GUILayout.Button(Labels.Validate))
            {
                DungeonValidator.Instance.Validate(data);
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(properties.KeyManager, Labels.KeyManager);
            EditorGUILayout.PropertyField(properties.Length, Labels.Length);

            // Doorway Connections
            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.LabelField(Labels.DoorwayConnectionHeader, EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(properties.DoorwayConnectionChance, Labels.DoorwayConnectionChance);
            EditorGUILayout.PropertyField(properties.RestrictConnectionToSameSection, Labels.RestrictConnectionToSameSection);
            EditorGUILayout.EndVertical();

            // Branch Mode
            EditorGUILayout.BeginVertical("box");

            EditorGUILayout.HelpBox(GetCurrentBranchModeLabel(), MessageType.Info);
            EditorGUILayout.PropertyField(properties.BranchMode, Labels.BranchMode);

            EditorGUI.BeginDisabledGroup(data.BranchMode != BranchMode.Global);
            EditorGUILayout.PropertyField(properties.BranchCount, Labels.BranchCount);
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (GUILayout.Button(Labels.OpenFlowEditor))
            {
                DungeonFlowEditorWindow.Open(data);
            }

            DrawTileInjectionRules(data);

            EditorGUILayout.Space();


            var globalProps = properties.GlobalProps.serializedProperty;

            globalProps.isExpanded = EditorGUILayout.Foldout(globalProps.isExpanded, Labels.GlobalProps, true);

            if (globalProps.isExpanded)
            {
                properties.GlobalProps.DoLayoutList();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(data);
            }

            serializedObject.ApplyModifiedProperties();
        }