void DrawFirstSection(GridGraph graph) { float prevRatio = graph.aspectRatio; DrawInspectorMode(graph); Draw2DMode(graph); var normalizedPivotPoint = NormalizedPivotPoint(graph, pivot); var worldPoint = graph.CalculateTransform().Transform(normalizedPivotPoint); int newWidth, newDepth; DrawWidthDepthFields(graph, out newWidth, out newDepth); EditorGUI.BeginChangeCheck(); float newNodeSize; if (graph.inspectorGridMode == InspectorGridMode.Hexagonal) { graph.inspectorHexagonSizeMode = (InspectorGridHexagonNodeSize)EditorGUILayout.EnumPopup(new GUIContent("Hexagon dimension"), graph.inspectorHexagonSizeMode); float hexagonSize = GridGraph.ConvertNodeSizeToHexagonSize(graph.inspectorHexagonSizeMode, graph.nodeSize); hexagonSize = (float)System.Math.Round(hexagonSize, 5); newNodeSize = GridGraph.ConvertHexagonSizeToNodeSize(graph.inspectorHexagonSizeMode, EditorGUILayout.FloatField(hexagonSizeContents[(int)graph.inspectorHexagonSizeMode], hexagonSize)); } else { newNodeSize = EditorGUILayout.FloatField(new GUIContent("Node size", "The size of a single node. The size is the side of the node square in world units"), graph.nodeSize); } bool nodeSizeChanged = EditorGUI.EndChangeCheck(); newNodeSize = newNodeSize <= 0.01F ? 0.01F : newNodeSize; if (graph.inspectorGridMode == InspectorGridMode.IsometricGrid || graph.inspectorGridMode == InspectorGridMode.Advanced) { graph.aspectRatio = EditorGUILayout.FloatField(new GUIContent("Aspect Ratio", "Scaling of the nodes width/depth ratio. Good for isometric games"), graph.aspectRatio); DrawIsometricField(graph); } if ((nodeSizeChanged && locked) || (newWidth != graph.width || newDepth != graph.depth) || prevRatio != graph.aspectRatio) { graph.nodeSize = newNodeSize; graph.SetDimensions(newWidth, newDepth, newNodeSize); normalizedPivotPoint = NormalizedPivotPoint(graph, pivot); var newWorldPoint = graph.CalculateTransform().Transform(normalizedPivotPoint); // Move the center so that the pivot point stays at the same point in the world graph.center += worldPoint - newWorldPoint; graph.center = RoundVector3(graph.center); graph.UpdateTransform(); AutoScan(); } if ((nodeSizeChanged && !locked)) { graph.nodeSize = newNodeSize; graph.UpdateTransform(); } DrawPositionField(graph); DrawRotationField(graph); }