Exemple #1
0
        void OnGUI()
        {
            scroll = GUILayout.BeginScrollView(scroll);
            float curLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = LABEL_WIDTH;

            settingsObject.Update();

            try {
                ImportantButtons();
            }
            catch (System.Exception e) {
                GUILayout.Label(string.Format("Exception has ocured in importand buttons.\n\nException:\n{0}", e));
            }

            UITools.Line();

            _showSettings = EditorGUILayout.Foldout(_showSettings, "Settings");
            if (_showSettings)
            {
                try {
                    ShowSettings();
                }
                catch (System.Exception e) {
                    GUILayout.Label(string.Format("Exception has ocured while showing settings.\n\nException:\n{0}", e));
                }
            }

            UITools.Line();


            _showDebuger = EditorGUILayout.Foldout(_showDebuger, "Debuger");
            if (_showDebuger)
            {
                try {
                    ShowDebuger();
                }
                catch (System.Exception e) {
                    GUILayout.Label(string.Format("Exception has ocured while showing debuger.\n\nException:\n{0}", e));
                }
            }

            UITools.Line();

            EditorGUIUtility.labelWidth = curLabelWidth;

            GUILayout.EndScrollView();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(settings);
                Debuger_K.SetSettingsDirty();
                Repaint();
            }

            settingsObject.ApplyModifiedProperties();
        }
Exemple #2
0
        private void ShowSettings()
        {
            if (settings == null)
            {
                settings = PathFinderSettings.LoadSettings();
            }

            EditorGUILayout.PropertyField(helperName, helperNameContent);

            if (useMultithread.boolValue)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(useMultithread, useMultithreadContent);
                EditorGUIUtility.labelWidth = 80;
                EditorGUILayout.PropertyField(maxThreads, maxThreadsContent);
                EditorGUIUtility.labelWidth = LABEL_WIDTH;
                GUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.PropertyField(useMultithread, useMultithreadContent);
            }

            EditorGUILayout.PropertyField(terrainCollectionType, terrainCollectionTypeContent);
            EditorGUILayout.PropertyField(colliderCollectionType, colliderCollectionTypeContent);

            float someFloat;

            EditorGUI.BeginChangeCheck();
            someFloat = EditorGUILayout.FloatField(gridSizeContent, gridSize.floatValue);
            if (EditorGUI.EndChangeCheck())
            {
                settings.gridSize   = someFloat;
                PathFinder.gridSize = someFloat;
            }

            GUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(gridLowest, gridLowestContent);
            EditorGUIUtility.labelWidth = 30;
            EditorGUILayout.PropertyField(gridHighest, gridHighestContent);
            EditorGUIUtility.labelWidth = LABEL_WIDTH;
            GUILayout.EndHorizontal();

            if (gridHighest.intValue < gridLowest.intValue)
            {
                gridHighest.intValue = gridLowest.intValue;
            }

            if (gridLowest.intValue > gridHighest.intValue)
            {
                gridLowest.intValue = gridHighest.intValue;
            }

            UITools.Line();
            settingsDrawer.DrawAreaEditor();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            AreaWorldMod currentTarget = (target as AreaWorldMod);

            Event e = Event.current;

            EditorGUILayout.PropertyField(priority, priorityContent);


            //this one is important
            EditorGUI.BeginChangeCheck();
            bool useAA = EditorGUILayout.ToggleLeft(useAdvancedAreaContent, currentTarget.useAdvancedArea);

            if (EditorGUI.EndChangeCheck())
            {
                //SceneView.RepaintAll();
                currentTarget.SetUseAdvancedArea(useAA);
            }

            if (currentTarget.useAdvancedArea)
            {
                EditorGUILayout.PropertyField(advancedArea);

                EditorGUI.BeginChangeCheck();
                bool startState = EditorGUILayout.ToggleLeft(cellUsabilityStateContent, currentTarget.cellUsabilityState);
                if (EditorGUI.EndChangeCheck())
                {
                    currentTarget.SetCellsState(startState);
                }
            }
            else
            {
                EditorGUILayout.PropertyField(areaInt);
            }

            UITools.Line();

            EditorGUILayout.PropertyField(drawGizmos, drawGizmosContent);

            if (drawGizmos.boolValue)
            {
                EditorGUILayout.PropertyField(drawGizmosAlpha, drawGizmosAlphaContent);
                EditorGUILayout.PropertyField(drawBounds, drawBoundsContent);
            }
            UITools.Line();
            EditorGUILayout.PropertyField(mode, modeContent);
            UITools.Line();
            //EditorGUILayout.PropertyField(serializedObject.FindProperty(filterString));
            //SmallUITools.Line();

            drawShapeList = EditorGUILayout.Foldout(drawShapeList, new GUIContent("Shape List"));

            if (drawShapeList)
            {
                GUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                editShape = EditorGUILayout.ToggleLeft("Edit Shape", editShape, GUILayout.MaxWidth(80));
                if (EditorGUI.EndChangeCheck())
                {
                    Repaint();
                    SceneView.RepaintAll();
                }

                curShape = (AreaWorldModMagicValueType)EditorGUILayout.EnumPopup(curShape);
                bool flag = false;
                if (GUILayout.Button("Add", GUILayout.MaxHeight(14)))
                {
                    Undo.RecordObject(target, "Add");
                    currentTarget.ShapeAdd(curShape);
                    flag = true;
                }
                if (flag)
                {
                    SceneView.RepaintAll();
                }
                GUILayout.EndHorizontal();

                Rect  lastRect             = GUILayoutUtility.GetLastRect();
                float lastHeight           = lastRect.y + lastRect.height;
                SerializedProperty allMods = serializedObject.FindProperty(allModsString);

                mouseOver = IndexedFlag.nope;
                cursorInsideSellectedArea = false;

                for (int i = 0; i < allMods.arraySize; i++)
                {
                    SerializedProperty arrayElement = allMods.GetArrayElementAtIndex(i);

                    float height  = EditorGUI.GetPropertyHeight(arrayElement) + 2;
                    Rect  boxRect = new Rect(0, lastHeight, Screen.width, height);

                    Color curColor = GUI.color;

                    if (boxRect.Contains(e.mousePosition))
                    {
                        mouseOver = new IndexedFlag(true, i);

                        GUI.color = colorSellectionMouseOver;
                        cursorInsideSellectedArea = true;

                        if (e.type == EventType.MouseDown)
                        {
                            if (e.button == 1)
                            {
                                int tempI = i;
                                onShapeClick = new GenericMenu();

                                if (tempI > 0)
                                {
                                    onShapeClick.AddItem(new GUIContent("Move Up"), false, () => {
                                        currentTarget.ShapeDecreaseValueID(tempI);
                                        mouseOver = IndexedFlag.nope;
                                        Repaint();
                                        SceneView.RepaintAll();
                                    });
                                }

                                if (tempI < allMods.arraySize - 1)
                                {
                                    onShapeClick.AddItem(new GUIContent("Move Down"), false, () => {
                                        currentTarget.ShapeIncreaseValueID(tempI);
                                        mouseOver = IndexedFlag.nope;
                                        Repaint();
                                        SceneView.RepaintAll();
                                    });
                                }

                                onShapeClick.AddItem(new GUIContent("Copy"), false, () => {
                                    currentTarget.ShapeCopyAt(tempI);
                                    mouseOver = IndexedFlag.nope;
                                    Repaint();
                                    SceneView.RepaintAll();
                                });

                                onShapeClick.AddItem(new GUIContent("Remove"), false, () => {
                                    currentTarget.ShapeRemoveAt(tempI);
                                    mouseOver = IndexedFlag.nope;
                                    Repaint();
                                    SceneView.RepaintAll();
                                });

                                onShapeClick.ShowAsContext();
                            }
                        }
                    }

                    GUI.Box(boxRect, string.Empty);

                    GUI.color = curColor;

                    EditorGUILayout.PropertyField(arrayElement);
                    lastHeight += height;
                }

                if (cursorInsideSellectedArea)
                {
                    Repaint();
                    SceneView.RepaintAll();
                }
                if (cursorInsideSellectedArea != tempFlagCursorInsideSellectedArea)
                {
                    tempFlagCursorInsideSellectedArea = cursorInsideSellectedArea;
                    Repaint();
                    SceneView.RepaintAll();
                }
            }
            UITools.Line();


            drawGameObjectList = EditorGUILayout.Foldout(drawGameObjectList, new GUIContent("GameObject List"));

            //Rect lastRec = GUILayoutUtility.GetLastRect();

            if (drawGameObjectList)
            {
                if (GUILayout.Button("Update Childs"))
                {
                    currentTarget.RebuildChilds(false);
                }

                TextAnchor curBoxAnchor = GUI.skin.box.alignment;
                GUI.skin.box.alignment = TextAnchor.MiddleLeft;
                foreach (var item in currentTarget.childsAndBounds.Keys)
                {
                    GUILayout.Box(item.name, GUILayout.MinWidth(200));
                }
                GUI.skin.box.alignment = curBoxAnchor;
            }

            if (currentTarget.CheckDirty())
            {
                Repaint();
                SceneView.RepaintAll();
            }

            if (serializedObject.ApplyModifiedProperties())
            {
                currentTarget.DirtyAll();
            }
        }
Exemple #4
0
        public override void OnInspectorGUI()
        {
            Event e = Event.current;

            serializedObject.Update();
            EditorGUI.showMixedValue = true;

            Color guiColor = GUI.color;

            if (properties.hasMultipleDifferentValues)
            {
                GUI.color = niceYellow;
            }
            else if (properties.objectReferenceValue != null)
            {
                GUI.color = niceGreen;
            }
            else
            {
                GUI.color = niceRed;
            }

            GUI.Box(lastPropertiesRect, string.Empty);
            GUI.color = guiColor;

            if (properties.hasMultipleDifferentValues)
            {
                EditorGUILayout.PropertyField(properties, agentPropertiesWarningYellow);
            }
            else if (properties.objectReferenceValue != null)
            {
                EditorGUILayout.PropertyField(properties, agentPropertiesDescription);
            }
            else
            {
                EditorGUILayout.PropertyField(properties, agentPropertiesWarningRed);
            }

            if (e.type == EventType.Repaint)
            {
                lastPropertiesRect = GUILayoutUtility.GetLastRect();
            }

            if (properties.objectReferenceValue != null)
            {
                EditorGUILayout.PropertyField(updateNavmeshPosition, updateNavmeshPositionContent);

                //updateNeighbourAgents
                if (updateNeighbourAgents.boolValue)
                {
                    GUILayout.Box(string.Empty, guiLayoutForNiceLine);
                }
                EditorGUILayout.PropertyField(updateNeighbourAgents, updateNeighbourAgentsContent);
                if (updateNeighbourAgents.boolValue)
                {
                    EditorGUILayout.PropertyField(maxNeighbors, maxNeighboursContent);
                    EditorGUILayout.PropertyField(maxNeighbourDistance, maxNeighbourDistanceContent);
                }
                if (updateNeighbourAgents.boolValue)
                {
                    GUILayout.Box(string.Empty, guiLayoutForNiceLine);
                }

                EditorGUILayout.PropertyField(velocityObstacle, velocityObstacleContent);
                if (velocityObstacle.boolValue)
                {
                    updateNavmeshPosition.boolValue = true;
                    updateNeighbourAgents.boolValue = true;

                    EditorGUILayout.PropertyField(maxAgentVelocity, maxAgentVelocityContent);
                    EditorGUILayout.PropertyField(avoidanceResponsibility, avoidanceResponsibilityContent);
                    EditorGUILayout.PropertyField(careDistance, careDistanceContent);

                    EditorGUILayout.PropertyField(useDeadLockFailsafe, useDeadLockFailsafeContent);
                    if (useDeadLockFailsafe.boolValue)
                    {
                        EditorGUILayout.PropertyField(deadLockVelocityThreshold, deadLockVelocityThresholdContent);
                        EditorGUILayout.PropertyField(deadLockFailsafeVelocity, deadLockFailsafeVelocityContent);
                        EditorGUILayout.PropertyField(deadLockFailsafeTime, deadLockFailsafeTimeContent);
                    }

                    EditorGUILayout.PropertyField(preferOneSideEvasion, preferOneSideEvasionContent);
                    if (preferOneSideEvasion.boolValue)
                    {
                        EditorGUILayout.PropertyField(preferOneSideEvasionOffset, preferOneSideEvasionOffsetContent);
                        if (preferOneSideEvasionOffset.floatValue < 0)
                        {
                            preferOneSideEvasionOffset.floatValue = 0f;
                        }
                    }
                }
            }


            UITools.Line();

            debugPath = EditorGUILayout.Toggle("Debug Path", debugPath);
            if (debugPath)
            {
                PathFinderAgent agent = (PathFinderAgent)target;
                if (agent != null && agent.path != null)
                {
                    lock (agent.path) {
                        for (int i = 0; i < agent.path.pathNodes.Count - 1; i++)
                        {
                            Debug.DrawLine(agent.path.pathNodes[i], agent.path.pathNodes[i + 1], Color.red);
                        }
                    }
                }
            }


            EditorGUI.showMixedValue = false;
            serializedObject.ApplyModifiedProperties();
        }
Exemple #5
0
        public override void OnInspectorGUI()
        {
            AgentProperties myTarget = (AgentProperties)target;

            if (myTarget == null)
            {
                return;
            }

            float currentLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 130;

            UITools.Line();
            generalTab = EditorGUILayout.Foldout(generalTab, generalTabContent);
            if (generalTab)
            {
                Rect rect = EditorGUILayout.GetControlRect(false, 100);
                //GUI.Box(rect, string.Empty);

                #region nice drawing
                float   rectHeight        = rect.height * 0.7f;
                float   rectheightHalf    = rectHeight * 0.5f;
                float   rectheightQuarter = rectheightHalf * 0.5f;
                Vector2 rectCenter        = rect.center;

                float agentWidth = (radius.floatValue / height.floatValue) * rectHeight * 0.8f;

                Vector2 leftBottom  = new Vector2(rectCenter.x + agentWidth + rectheightQuarter, rectCenter.y + rectheightHalf);
                Vector2 rightBotton = new Vector2(rectCenter.x - agentWidth - rectheightQuarter, rectCenter.y + rectheightHalf);

                Handles.color = Color.black;

                float   slope       = maxSlope.floatValue;
                Vector2 slopeVector = new Vector2(
                    (float)Math.Cos(slope * Math.PI / 180) * (rectHeight * 0.9f),
                    (float)Math.Sin(slope * Math.PI / 180) * (rectHeight * 0.9f));

                slopeVector = new Vector2(-slopeVector.x, slopeVector.y);


                GUI.Label(new Rect((leftBottom - (slopeVector * 0.15f)) - (new Vector2(0, 15)), new Vector2(100, 20)), string.Format("Slope {0}", maxSlope.floatValue));


                float stepHeight = (maxStepHeight.floatValue / height.floatValue) * rectHeight;

                Handles.DrawAAPolyLine(
                    3,
                    leftBottom - slopeVector,
                    leftBottom,
                    rightBotton,
                    rightBotton - new Vector2(0, stepHeight),
                    rightBotton - new Vector2(50, stepHeight));

                GUI.Label(new Rect(rightBotton - new Vector2(50, stepHeight + 20), new Vector2(100, 20)), string.Format("Step {0}", maxStepHeight.floatValue));

                //Vector2 leftStart = rectCenter - new Vector2(rectheightQuarter, rectheightQuarter);
                //Vector2 leftUp = leftStart + new Vector2(0, rectheightHalf);

                Color hColor = Handles.color;
                Handles.color = Color.black;

                Color niceColor = new Color(135f / 255f, 206f / 255f, 250f / 255f, 1f);

                Handles.color = niceColor;
                Handles.DrawSolidDisc(new Vector2(rectCenter.x, rectCenter.y - rectheightHalf), new Vector3(0f, -1f, 0.5f), agentWidth);
                Handles.DrawSolidDisc(new Vector2(rectCenter.x, rectCenter.y + rectheightHalf), new Vector3(0f, 1f, 0.5f), agentWidth);
                EditorGUI.DrawRect(new Rect(
                                       rectCenter.x - agentWidth,
                                       rectCenter.y - rectheightHalf,
                                       agentWidth + agentWidth,
                                       rectheightHalf * 2), niceColor);

                Vector2 rectCenterSlightlyOffseted = new Vector2(rectCenter.x - 0.5f, rectCenter.y);

                textFieldStyles.normal.textColor = Color.red;
                GUI.Label(new Rect(rectCenter.x + agentWidth, rectCenter.y, 100, 20), string.Format("Radius {0}", radius.floatValue), textFieldStyles);

                textFieldStyles.normal.textColor = Color.blue;
                GUI.Label(new Rect(rectCenter.x + agentWidth, rectCenter.y - rectheightHalf, 100, 20), string.Format("Height {0}", height.floatValue), textFieldStyles);

                //outlines
                Handles.color = Color.black;
                Handles.DrawWireDisc(new Vector2(rectCenterSlightlyOffseted.x, rectCenterSlightlyOffseted.y - rectheightHalf), new Vector3(0f, 1f, 0.5f), agentWidth);
                Handles.DrawWireDisc(new Vector2(rectCenterSlightlyOffseted.x, rectCenterSlightlyOffseted.y - rectheightHalf), new Vector3(0f, -1f, 0.5f), agentWidth);
                Handles.DrawWireDisc(new Vector2(rectCenterSlightlyOffseted.x, rectCenterSlightlyOffseted.y + rectheightHalf), new Vector3(0f, 1f, 0.5f), agentWidth);

                Handles.DrawLine(
                    new Vector2(rectCenterSlightlyOffseted.x - agentWidth, rectCenterSlightlyOffseted.y - rectheightHalf),
                    new Vector2(rectCenterSlightlyOffseted.x - agentWidth, rectCenterSlightlyOffseted.y + rectheightHalf));

                Handles.DrawLine(
                    new Vector2(rectCenterSlightlyOffseted.x + agentWidth, rectCenterSlightlyOffseted.y - rectheightHalf),
                    new Vector2(rectCenterSlightlyOffseted.x + agentWidth, rectCenterSlightlyOffseted.y + rectheightHalf));


                Handles.color = Color.red;
                Handles.DrawWireDisc(rectCenterSlightlyOffseted, new Vector3(0f, 1f, 0.5f), agentWidth);
                Handles.DrawWireDisc(rectCenterSlightlyOffseted + Vector2.up, new Vector3(0f, 1f, 0.5f), agentWidth);
                Handles.DrawWireDisc(rectCenterSlightlyOffseted + Vector2.down, new Vector3(0f, 1f, 0.5f), agentWidth);

                Handles.color = hColor;
                #endregion

                EditorGUILayout.PropertyField(radius, radiusContent);
                EditorGUILayout.PropertyField(height, heightContent);
                EditorGUILayout.PropertyField(maxSlope, maxSlopeContent);
                EditorGUILayout.PropertyField(maxStepHeight, maxStepHeightContent);
                EditorGUILayout.PropertyField(includedLayers, includedLayersContent);
                EditorGUILayout.PropertyField(ignoredTags, ignoredTagsContent, true);
                if (ignoredTags.arraySize > 0)
                {
                    EditorGUILayout.PropertyField(checkHierarchyTag, checkHierarchyTagContent);
                }

                if (maxStepHeight.floatValue > height.floatValue)
                {
                    maxStepHeight.floatValue = height.floatValue;
                }

                if (canCrouch.boolValue && maxStepHeight.floatValue > crouchHeight.floatValue)
                {
                    maxStepHeight.floatValue = crouchHeight.floatValue;
                }

                if (radius.floatValue < 0.001f)
                {
                    radius.floatValue = 0.001f;
                }

                if (height.floatValue < 0.001f)
                {
                    height.floatValue = 0.001f;
                }

                if (maxStepHeight.floatValue < 0.001f)
                {
                    maxStepHeight.floatValue = 0.001f;
                }

                if (includedLayers.intValue == 0)    //big warning in case no layers sellected
                {
                    rect = EditorGUILayout.GetControlRect(false, 30);
                    Color gColor = GUI.color;
                    GUI.color = Color.red;
                    GUI.Box(rect, new GUIContent("No layers sellected", "Sellect at least something in included Layers"));
                    GUI.color = gColor;
                }

                if (maxStepHeight.floatValue < (PathFinder.gridSize / myTarget.voxelsPerChunk))    //big warning in case no layers sellected
                {
                    rect = EditorGUILayout.GetControlRect(false, 30);
                    Color gColor = GUI.color;
                    GUI.color = Color.yellow;
                    GUI.Box(rect, new GUIContent("Step height is very low", "Agent probably will have incorrect navmesh generation if it that low. Recomend at least greater than voxel size"));
                    GUI.color = gColor;
                }
            }

            UITools.Line();

            voxelTab = EditorGUILayout.Foldout(voxelTab, voxelTabContent);

            if (voxelTab)
            {
                EditorGUILayout.PropertyField(voxelsPerChunk, voxelsPerChunkContent);

                float foxelSize = PathFinder.gridSize / myTarget.voxelsPerChunk;
                EditorGUILayout.LabelField("Voxel Size", foxelSize.ToString());

                EditorGUILayout.LabelField("Voxel Per Radius", ((int)(myTarget.radius / foxelSize)).ToString());

                GUILayout.BeginHorizontal();
                setThisMuch = EditorGUILayout.IntField(setThisMuch, GUILayout.MaxWidth(100));
                if (GUILayout.Button("Set this much"))
                {
                    voxelsPerChunk.intValue = Mathf.CeilToInt(PathFinder.gridSize / (myTarget.radius / setThisMuch));
                }

                if (voxelsPerChunk.intValue < setThisMuch)
                {
                    voxelsPerChunk.intValue = voxelsPerChunk.intValue + 1;
                }

                GUILayout.EndHorizontal();

                if (voxelsPerChunk.intValue < 10)
                {
                    voxelsPerChunk.intValue = 10;
                }

                if ((int)(myTarget.radius / foxelSize) <= 0)    //big warning in case no layers sellected
                {
                    Rect  rect   = EditorGUILayout.GetControlRect(false, 30);
                    Color gColor = GUI.color;
                    GUI.color = Color.red;
                    GUI.Box(rect, new GUIContent("Voxel per radius is 0", "Increase amount of voxels per radius. Recomend at least 2"));
                    GUI.color = gColor;
                }
            }

            UITools.Line();

            movementTab = EditorGUILayout.Foldout(movementTab, movementTabContent);
            if (movementTab)
            {
                EditorGUILayout.PropertyField(doNavMesh, doNavMeshContent);
                if (doNavMesh.boolValue)
                {
                    EditorGUILayout.PropertyField(walkMod, walkModContent);
                    EditorGUILayout.PropertyField(canCrouch, canCrouchContent);

                    if (canCrouch.boolValue)
                    {
                        EditorGUILayout.PropertyField(crouchHeight, crouchHeightContent);
                        EditorGUILayout.PropertyField(crouchMod, crouchModContent);

                        if (crouchHeight.floatValue < 0)
                        {
                            crouchHeight.floatValue = 0;
                        }

                        if (crouchHeight.floatValue > height.floatValue)
                        {
                            crouchHeight.floatValue = height.floatValue;
                        }
                    }

                    EditorGUILayout.PropertyField(canJump, canJumpContent);

                    if (canJump.boolValue)
                    {
                        EditorGUILayout.PropertyField(JumpDown, JumpDownContent);
                        EditorGUILayout.PropertyField(jumpDownMod, jumpDownModContent);
                        EditorGUILayout.PropertyField(JumpUp, JumpUpContent);
                        EditorGUILayout.PropertyField(jumpUpMod, jumpUpModContent);
                    }
                }
            }

            UITools.Line();
            coverTab = EditorGUILayout.Foldout(coverTab, coverTabContent);
            if (coverTab)
            {
                EditorGUILayout.PropertyField(canCover, canCoverContent);
                if (canCover.boolValue)
                {
                    EditorGUILayout.PropertyField(fullCover, fullCoverContent);
                    if (fullCover.floatValue < 0)
                    {
                        fullCover.floatValue = 0;
                    }

                    EditorGUILayout.PropertyField(canHalfCover, canHalfCoverContent);

                    if (canHalfCover.boolValue)
                    {
                        EditorGUILayout.PropertyField(halfCover, halfCoverContent);

                        halfCover.floatValue = SomeMath.Clamp(0, fullCover.floatValue, halfCover.floatValue);

                        if (fullCover.floatValue < halfCover.floatValue)
                        {
                            fullCover.floatValue = halfCover.floatValue;
                        }
                    }

                    EditorGUILayout.PropertyField(coverExtraSamples, coverExtraSamplesContent);
                    if (coverExtraSamples.intValue < 0)
                    {
                        coverExtraSamples.intValue = 0;
                    }
                }
            }

            UITools.Line();

            battleGridTab = EditorGUILayout.Foldout(battleGridTab, battleGridTabContent);
            if (battleGridTab)
            {
                EditorGUILayout.PropertyField(battleGrid, battleGridContent);
                if (battleGrid.boolValue)
                {
                    EditorGUILayout.PropertyField(battleGridDensity, battleGridDensityContent);
                }
            }

            UITools.Line();

            otherTab = EditorGUILayout.Foldout(otherTab, otherTabContent);
            if (otherTab)
            {
                EditorGUILayout.PropertyField(offsetMultiplier, offsetMultiplierContent);
            }

            EditorGUIUtility.labelWidth = currentLabelWidth;
            serializedObject.ApplyModifiedProperties();
        }
        public void DrawAreaEditor()
        {
            settings.drawAreaEditor = EditorGUILayout.Foldout(settings.drawAreaEditor, "Area Editor");

            if (!settings.drawAreaEditor)
            {
                return;
            }

            if (GUILayout.Button("Add Area"))
            {
                settings.AddArea();
            }

            for (int i = 0; i < settings.areaLibrary.Count; i++)
            {
                bool remove = false;
                Area area   = settings.areaLibrary[i];

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(area.id.ToString(), GUILayout.MaxWidth(10f));
                if (area.id == 0 || area.id == 1)  //cant choose name to default areas to avoit confussion
                {
                    EditorGUILayout.LabelField(new GUIContent(area.name, "area name"), GUILayout.MaxWidth(80));
                }
                else
                {
                    area.name = EditorGUILayout.TextField(area.name, GUILayout.MaxWidth(80));
                }

                area.color = EditorGUILayout.ColorField(GUIContent.none, area.color, false, false, false, GUILayout.MaxWidth(12f));

                EditorGUILayout.LabelField(new GUIContent("Cost", "move cost"), GUILayout.MaxWidth(30));

                if (area.id == 1)
                {
                    EditorGUILayout.LabelField("max", GUILayout.MaxWidth(30f));
                }
                else
                {
                    area.cost = EditorGUILayout.FloatField(area.cost, GUILayout.MaxWidth(30f));
                }


                EditorGUILayout.LabelField(new GUIContent("Priority", "z-fighting cure. if one layer on another than this number matter"), GUILayout.MaxWidth(45f));

                if (area.id == 1)
                {
                    EditorGUILayout.LabelField(new GUIContent("-1", "clear area it always should be -1"), GUILayout.MaxWidth(30f));
                }
                else
                {
                    area.overridePriority = EditorGUILayout.IntField(area.overridePriority, GUILayout.MaxWidth(30f));
                    if (area.overridePriority < 0)
                    {
                        area.overridePriority = 0;
                    }
                }

                if (area.id != 0 && area.id != 1)
                {
                    remove = GUILayout.Button("X", GUILayout.MaxWidth(18f));
                }

                EditorGUILayout.EndHorizontal();

                if (remove)
                {
                    settings.RemoveArea(i);
                    break;
                }
            }
            UITools.Line();
            settings.drawUnityAssociations = EditorGUILayout.Foldout(settings.drawUnityAssociations, "Tag Associations");

            if (settings.drawUnityAssociations)
            {
                settings.checkRootTag = EditorGUILayout.ToggleLeft("Use Root Tag", settings.checkRootTag);

                settings.CheckTagAssociations();

                TextAnchor curAnchor = GUI.skin.box.alignment;
                GUI.skin.box.alignment = TextAnchor.MiddleLeft;
                Color curColor = GUI.color;
                foreach (var pair in PathFinderSettings.tagAssociations)
                {
                    EditorGUILayout.BeginHorizontal();

                    GUILayout.Box(pair.Key, GUILayout.ExpandWidth(true), GUILayout.MaxWidth(EditorGUIUtility.labelWidth));
                    GUI.color = settings.areaLibrary[pair.Value.id].color;
                    GUILayout.Box(string.Empty, GUILayout.MaxWidth(15));
                    GUI.color = curColor;

                    EditorGUI.BeginChangeCheck();
                    int tempValue = EditorGUILayout.IntPopup(
                        pair.Value.id, PathFinder.settings.areaNames, PathFinder.settings.areaIDs);
                    if (EditorGUI.EndChangeCheck())
                    {
                        PathFinderSettings.tagAssociations[pair.Key] = settings.areaLibrary[tempValue];
                    }
                    EditorGUILayout.EndHorizontal();
                }
                GUI.color = curColor;
                GUI.skin.box.alignment = curAnchor;
            }
        }