public override void OnInspectorGUI() { if (Application.isPlaying) { EditorGUILayout.HelpBox("These settings cannot be edited in play mode.", MessageType.Info); return; } var lb = this.target as LoadBalancerComponent; EditorGUILayout.Separator(); EditorGUI.indentLevel += 1; foreach (var cfg in lb.configurations) { bool foldOut = false; _foldedOut.TryGetValue(cfg.targetLoadBalancer, out foldOut); _foldedOut[cfg.targetLoadBalancer] = EditorGUILayout.Foldout(foldOut, cfg.targetLoadBalancer.ExpandFromPascal()); if (_foldedOut[cfg.targetLoadBalancer]) { if (DrawConfigEditor(cfg)) { EditorUtility.SetDirty(lb); } } } EditorUtilities.Section("Marshaller"); this.serializedObject.Update(); EditorGUILayout.PropertyField(_mashallerMaxMillisecondPerFrame, new GUIContent("Max Milliseconds Per Frame", "The maximum number of milliseconds per frame to allow for marshalling calls onto the main thread.")); this.serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { GUI.enabled = !EditorApplication.isPlaying; this.serializedObject.Update(); EditorUtilities.Section("Path Finder Options"); EditorGUILayout.PropertyField(_pathingPriority); EditorGUILayout.PropertyField(_usePathSmoothing); EditorGUILayout.PropertyField(_optimizeUnobstructedPaths); EditorGUILayout.PropertyField(_allowCornerCutting); EditorGUILayout.PropertyField(_preventDiagonalMoves); EditorGUILayout.PropertyField(_navigateToNearestIfBlocked); EditorGUILayout.PropertyField(_maxEscapeCellDistanceIfOriginBlocked); EditorUtilities.Section("Path Following"); EditorGUILayout.PropertyField(_nextNodeDistance); EditorGUILayout.PropertyField(_requestNextWaypointDistance); EditorGUILayout.PropertyField(_announceAllNodes); EditorUtilities.Section("Replanning"); EditorGUILayout.PropertyField(_replanMode); EditorGUILayout.PropertyField(_replanInterval); this.serializedObject.ApplyModifiedProperties(); GUI.enabled = true; }
private void ShowHeightMapOptions() { var heightMode = GameServices.heightStrategy.heightMode; if (heightMode == HeightSamplingMode.HeightMap) { EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_generateHeightMap, new GUIContent("Generate Height Map", "Controls whether the grid generates a height map to allow height sensitive navigation.")); if (_generateHeightMap.boolValue) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_heightLookupType, new GUIContent("Lookup Type", "Dictionaries are fast but dense. Quad Trees are sparse but slower and are very dependent on height distributions. Use Quad trees on maps with large same height areas.")); if (_heightLookupType.intValue == (int)HeightLookupType.QuadTree) { EditorGUILayout.PropertyField(_heightLookupMaxDepth, new GUIContent("Tree Depth", "The higher the allowed depth, the more sparse the tree will be but it will also get slower.")); } EditorGUI.indentLevel--; } } else { EditorUtilities.Section("Height Map"); EditorGUILayout.HelpBox(string.Format("Height navigation mode has been set to {0} (on Game World), hence no height map will be created.", heightMode), MessageType.Info); } }
private void ShowHeightMapOptions() { if (_heightStrategyMissing || GameServices.heightStrategy.heightMode == HeightSamplingMode.HeightMap) { EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_generateHeightMap); if (_generateHeightMap.boolValue) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_heightLookupType); if (_heightLookupType.intValue == (int)HeightLookupType.QuadTree) { EditorGUILayout.PropertyField(_heightLookupMaxDepth); } EditorGUI.indentLevel--; } } else { EditorUtilities.Section("Height Map"); EditorGUILayout.HelpBox(string.Format("Height navigation mode has been set to {0} (on Game World), hence no height map will be created.", GameServices.heightStrategy.heightMode), MessageType.Info); } }
public override void OnInspectorGUI() { if (Application.isPlaying) { EditorGUILayout.HelpBox("These settings cannot be edited in play mode.", MessageType.Info); return; } this.serializedObject.Update(); EditorUtilities.Section("Path Finder Options"); EditorGUILayout.PropertyField(_pathingPriority); EditorGUILayout.PropertyField(_usePathSmoothing); EditorGUILayout.PropertyField(_allowCornerCutting); EditorGUILayout.PropertyField(_preventDiagonalMoves); EditorGUILayout.PropertyField(_navigateToNearestIfBlocked); EditorGUILayout.PropertyField(_maxEscapeCellDistanceIfOriginBlocked); EditorUtilities.Section("Path Following"); EditorGUILayout.PropertyField(_nextNodeDistance); EditorGUILayout.PropertyField(_requestNextWaypointDistance); EditorGUILayout.PropertyField(_announceAllNodes); EditorUtilities.Section("Replanning"); EditorGUILayout.PropertyField(_replanMode); EditorGUILayout.PropertyField(_replanInterval); this.serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (Application.isPlaying) { EditorGUILayout.HelpBox("These settings cannot be edited in play mode.", MessageType.Info); return; } this.serializedObject.Update(); EditorUtilities.Section("Path Finder Options"); EditorGUILayout.PropertyField(_pathingPriority, new GUIContent("Pathing Priority", "The priority with which this unit's path requests should be processed.")); EditorGUILayout.PropertyField(_usePathSmoothing, new GUIContent("Use Path Smoothing", "Whether to use path smoothing to create more natural paths.")); EditorGUILayout.PropertyField(_allowCornerCutting, new GUIContent("Allow Corner Cutting", "Whether to allow the path to cut corners. Corner cutting has slightly better performance, but produces less natural routes.")); EditorGUILayout.PropertyField(_preventDiagonalMoves, new GUIContent("Prevent Diagonal Moves", "Whether the unit is allowed to move to diagonal neighbours.")); EditorGUILayout.PropertyField(_navigateToNearestIfBlocked, new GUIContent("Navigate To Nearest If Blocked", "Whether the unit will navigate to the nearest possible position if the actual destination is blocked or otherwise inaccessible.")); EditorGUILayout.PropertyField(_maxEscapeCellDistanceIfOriginBlocked, new GUIContent("Max Escape Cell Distance If Origin Blocked", "The maximum escape cell distance if the unit's starting position is blocked.")); EditorUtilities.Section("Path Following"); EditorGUILayout.PropertyField(_nextNodeDistance, new GUIContent("Next Node Distance", "The distance from the current destination node on the path at which the unit will switch to the next node.")); EditorGUILayout.PropertyField(_requestNextWaypointDistance, new GUIContent("Request Next Waypoint Distance", "The distance from the current way point at which the next way point will be requested.")); EditorGUILayout.PropertyField(_announceAllNodes, new GUIContent("Announce All Nodes", "Whether to raise a navigation event for each node reached along a path.")); EditorUtilities.Section("Replanning"); EditorGUILayout.PropertyField(_replanMode, new GUIContent("Replan Mode", "The replan mode.")); EditorGUILayout.PropertyField(_replanInterval, new GUIContent("Replan Interval", "The time between replans, the exact meaning depends on the replan mode.")); this.serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (Application.isPlaying) { EditorGUILayout.HelpBox("These settings cannot be edited in play mode.", MessageType.Info); return; } this.serializedObject.Update(); EditorUtilities.Section("Height Sampling"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_heightSampling); if (EditorGUI.EndChangeCheck()) { DefaultHeightNavigatorEditor.EnsureValidProviders((HeightSamplingMode)_heightSampling.intValue); } if (_heightSampling.intValue == (int)HeightSamplingMode.HeightMap) { EditorGUILayout.PropertyField(_heightMapDetail); } bool isFlat = (_heightSampling.intValue == (int)HeightSamplingMode.NoHeightSampling); if (!isFlat) { EditorGUILayout.PropertyField(_heightSamplingGranularity); EditorGUILayout.PropertyField(_ledgeThreshold); EditorGUILayout.Separator(); EditorGUI.indentLevel--; EditorGUILayout.PropertyField(_useGlobalHeightNavigationSettings); if (_useGlobalHeightNavigationSettings.boolValue) { EditorGUILayout.PropertyField(_unitsHeightNavigationCapability, GUIContent.none, true); } } EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_useClearance); if (!isFlat && _useClearance.boolValue) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_heightDiffThreshold); EditorGUI.indentLevel--; } InspectorGUI(); this.serializedObject.ApplyModifiedProperties(); if (GUI.changed) { var t = this.target as NavigationSettingsComponent; t.Refresh(); } }
protected override void CreateUI() { base.CreateUI(); EditorUtilities.Section("Containment"); EditorGUILayout.PropertyField(_bufferDistance); EditorGUI.indentLevel -= 1; EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_drawGizmos); }
protected override void CreateUI() { base.CreateUI(); EditorUtilities.Section("Blocked Cell Repulsion"); EditorGUILayout.PropertyField(_radiusMargin); EditorGUILayout.PropertyField(_repulsionStrength); EditorGUI.indentLevel -= 1; EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_drawGizmos); }
protected override void CreateUI() { base.CreateUI(); EditorUtilities.Section("Formation"); EditorGUILayout.PropertyField(_samplingUpdateInterval); EditorGUILayout.PropertyField(_sampledCellCount); EditorGUILayout.PropertyField(_maxFormationRadius); EditorGUILayout.PropertyField(_dropFormationOnArrival); EditorGUI.indentLevel -= 1; EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_debugDraw); }
public override void OnInspectorGUI() { this.serializedObject.Update(); EditorUtilities.Section("Obstruction"); EditorGUILayout.PropertyField(_exceptions, new GUIContent("Exceptions", "Units with one or more matching attributes will not consider this obstacle when path finding, e.g. useful for doors etc..")); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_updateMode, new GUIContent("Update Mode", "Controls when the obstacle updates its state, and thereby its associated grid.")); EditorGUILayout.PropertyField(_customUpdateInterval, new GUIContent("Custom Update Interval", "Setting this to a value other than 0, will override the default update interval of the load balancer.")); ExtensionOnGUI(); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_useGridObstacleSensitivity, new GUIContent("Use Grid Obstacle Sensitivity", "Controls whether the obstacle sensitivity range of the grid will be used by this obstacle.")); if (_useGridObstacleSensitivity.boolValue == false) { EditorGUILayout.PropertyField(_customSensitivity, new GUIContent("Custom Sensitivity", "The custom obstacle sensitivity range to use.")); } EditorUtilities.Section("Grid interaction"); EditorGUILayout.PropertyField(_supportDynamicGrids, new GUIContent("Support Dynamic Grids", "If checked, the Dynamic Obstacle will react to grids being disabled / initialized at runtime. If you use dynamic grid initialization this should be checked.")); EditorGUILayout.PropertyField(_causesReplanning, new GUIContent("Causes Replanning", "Controls whether the dynamic obstacle will trigger path replanning for unit's in the grid sections it influences.")); EditorUtilities.Section("Velocity"); EditorGUILayout.PropertyField(_velocityPredictionFactor, new GUIContent("Velocity Prediction Factor", "Determines how far in the obstacles direction of movement, that cells will be considered blocked.")); EditorGUILayout.PropertyField(_resolveVelocityFromParent, new GUIContent("Resolve Velocity from Parent", "Controls whether the obstacle will look for a velocity source on the parent game object if one is not found on its own.")); EditorGUILayout.PropertyField(_stopUpdatingIfStationary, new GUIContent("Stop Updating If Stationary", "Setting this to true, will stop the dynamic updates if the obstacle remains stationary for 'Stationary Threshold Seconds' seconds.")); if (_stopUpdatingIfStationary.boolValue == true) { EditorGUILayout.PropertyField(_stationaryThresholdSeconds, new GUIContent("Stationary Threshold Seconds", "The amount of seconds after which dynamic updates on the obstacle will stop.")); } this.serializedObject.ApplyModifiedProperties(); if (Application.isPlaying && GUI.changed) { var t = this.target as ISupportRuntimeStateChange; if (t != null) { t.ReevaluateState(); } } }
public override void OnInspectorGUI() { this.serializedObject.Update(); EditorUtilities.Section("Obstruction"); EditorGUILayout.PropertyField(_exceptions); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_updateMode); EditorGUILayout.PropertyField(_customUpdateInterval); ExtensionOnGUI(); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_useGridObstacleSensitivity); if (_useGridObstacleSensitivity.boolValue == false) { EditorGUILayout.PropertyField(_customSensitivity); } EditorUtilities.Section("Grid interaction"); EditorGUILayout.PropertyField(_supportDynamicGrids); EditorGUILayout.PropertyField(_causesReplanning); EditorUtilities.Section("Velocity"); EditorGUILayout.PropertyField(_velocityPredictionFactor); EditorGUILayout.PropertyField(_resolveVelocityFromParent); EditorGUILayout.PropertyField(_stopUpdatingIfStationary); if (_stopUpdatingIfStationary.boolValue == true) { EditorGUILayout.PropertyField(_stationaryThresholdSeconds); } this.serializedObject.ApplyModifiedProperties(); if (Application.isPlaying && GUI.changed) { var t = this.target as ISupportRuntimeStateChange; if (t != null) { t.ReevaluateState(); } } }
protected override void CreateUI() { base.CreateUI(); EditorUtilities.Section("Arrival"); EditorGUILayout.PropertyField(_slowingAlgorithm); EditorGUILayout.PropertyField(_autoCalculateSlowingDistance); if (!_autoCalculateSlowingDistance.boolValue) { EditorGUI.indentLevel += 1; EditorGUILayout.PropertyField(_slowingDistance); EditorGUI.indentLevel -= 1; } EditorGUILayout.PropertyField(_arrivalDistance); EditorGUI.indentLevel -= 1; }
protected override void CreateUI() { base.CreateUI(); EditorUtilities.Section("Arrival"); EditorGUILayout.PropertyField(_slowingAlgorithm, new GUIContent("Slowing Algorithm", "The algorithm used to slow the unit for arrival.")); EditorGUILayout.PropertyField(_autoCalculateSlowingDistance, new GUIContent("Auto Calculate Slowing Distance", "Determines whether the slowing distance is automatically calculated based on the unit's speed and deceleration capabilities.")); if (!_autoCalculateSlowingDistance.boolValue) { EditorGUI.indentLevel += 1; EditorGUILayout.PropertyField(_slowingDistance, new GUIContent("Slowing Distance", "The distance within which the unit will start to slow down for arrival.")); EditorGUI.indentLevel -= 1; } EditorGUILayout.PropertyField(_arrivalDistance, new GUIContent("Arrival Distance", "The distance from the final destination where the unit will stop.")); EditorGUI.indentLevel -= 1; }
public override void OnInspectorGUI() { if (Application.isPlaying) { EditorGUILayout.HelpBox("These settings cannot be edited in play mode.", MessageType.Info); return; } this.serializedObject.Update(); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_attributeMask); EditorUtilities.Section("Selection"); EditorGUILayout.PropertyField(_isSelectable); if (_isSelectable.boolValue) { EditorGUILayout.PropertyField(_selectionVisual); } // set indention level back to normal EditorGUI.indentLevel -= 1; var heightStrategy = GameServices.heightStrategy; if (heightStrategy.useGlobalHeightNavigationSettings || heightStrategy.heightMode == HeightSamplingMode.NoHeightSampling) { EditorUtilities.Section("Height Navigation"); EditorGUILayout.HelpBox("Height navigation capabilities have been set globally on the Game World, which applies to all units.", MessageType.Info); } else { EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_heightCapabilities, new GUIContent("Height Navigation", "Represents the height navigation capabilities of the unit."), true); } EditorUtilities.Section("Misc"); EditorGUILayout.PropertyField(_radius); EditorGUILayout.PropertyField(_fieldOfView); EditorGUILayout.PropertyField(_yAxisoffset); EditorGUILayout.PropertyField(_determination, new GUIContent("Determination", "The determination factor is used to evaluate whether this unit separates or avoids other units. Units with lower determination are basically ignored.")); this.serializedObject.ApplyModifiedProperties(); }
protected override void CreateUI() { base.CreateUI(); EditorUtilities.Section("Separation"); EditorGUILayout.PropertyField(_maximumUnitsToConsider); EditorGUILayout.PropertyField(_separationStrength); EditorGUILayout.PropertyField(_separationDistance); EditorGUILayout.PropertyField(_minimumForceMagnitude); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_blockedNeighboursBehaviour); EditorGUI.indentLevel -= 1; EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_drawGizmos); }
protected virtual void CreateUI() { EditorUtilities.Section("Rotation"); EditorGUILayout.PropertyField(_maxAngularAcceleration); EditorGUILayout.PropertyField(_maxAngularSpeed); EditorUtilities.Section("Movement"); EditorGUILayout.PropertyField(_maxAcceleration); EditorGUILayout.PropertyField(_maxDeceleration); if (!this.hideMinSpeed) { EditorGUILayout.PropertyField(_minimumSpeed); } if (!this.hideMaxSpeed) { EditorGUILayout.PropertyField(_maximumSpeed); } }
protected override void CreateUI() { base.CreateUI(); EditorUtilities.Section("Avoidance"); EditorGUILayout.PropertyField(_ignoredUnits); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_radiusMargin); EditorGUILayout.PropertyField(_minimumAvoidVectorMagnitude); EditorGUILayout.PropertyField(_headOnCollisionAngle); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_accumulateAvoidVectors); EditorGUILayout.PropertyField(_preventPassingInFront); EditorGUI.indentLevel -= 1; EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_drawGizmos); }
public override void OnInspectorGUI() { GUI.enabled = !EditorApplication.isPlaying; this.serializedObject.Update(); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_attributeMask); EditorUtilities.Section("Selection"); EditorGUILayout.PropertyField(_isSelectable); if (_isSelectable.boolValue) { EditorGUILayout.PropertyField(_selectionVisual); } // set indention level back to normal EditorGUI.indentLevel -= 1; if (!_heightStrategyMissing && (GameServices.heightStrategy.useGlobalHeightNavigationSettings || GameServices.heightStrategy.heightMode == HeightSamplingMode.NoHeightSampling)) { EditorUtilities.Section("Height Navigation"); EditorGUILayout.HelpBox("Height navigation capabilities have been set globally on the Game World, which applies to all units.", MessageType.Info); } else { EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_heightCapabilities, new GUIContent("Height Navigation", "Represents the height navigation capabilities of the unit."), true); } EditorUtilities.Section("Misc"); EditorGUILayout.PropertyField(_radius); EditorGUILayout.PropertyField(_fieldOfView); EditorGUILayout.PropertyField(_yAxisoffset); EditorGUILayout.PropertyField(_determination); this.serializedObject.ApplyModifiedProperties(); GUI.enabled = true; }
public override void OnInspectorGUI() { GUI.enabled = !EditorApplication.isPlaying; this.serializedObject.Update(); int baked = 0; var editedObjects = this.serializedObject.targetObjects; for (int i = 0; i < editedObjects.Length; i++) { var g = editedObjects[i] as GridComponent; if (g.bakedData != null) { baked++; } } EditorGUILayout.Separator(); if (baked > 0 && baked < editedObjects.Length) { EditorGUILayout.LabelField("A mix of baked and unbaked grids cannot be edited at the same time."); return; } //If data is baked, only offer an option to edit or rebake if (baked == editedObjects.Length) { EditorGUILayout.LabelField("The grid has been baked. To change it press the Edit button below."); GUILayout.BeginHorizontal(); if (GUILayout.Button("Edit")) { foreach (var o in editedObjects) { var g = o as GridComponent; EditorUtilitiesInternal.RemoveAsset(g.bakedData); g.bakedData = null; g.ResetGrid(); EditorUtility.SetDirty(g); } } if (GUILayout.Button("Re-bake Grid")) { foreach (var o in editedObjects) { var g = o as GridComponent; BakeGrid(g); } } GUILayout.EndHorizontal(); return; } EditorGUILayout.PropertyField(_friendlyName); EditorUtilities.Section("Layout"); EditorGUILayout.PropertyField(_linkOriginToTransform); if (!_linkOriginToTransform.hasMultipleDifferentValues) { if (_linkOriginToTransform.boolValue) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_originOffset, true); EditorGUI.indentLevel--; } else { EditorGUILayout.PropertyField(_origin, true); } } EditorGUILayout.PropertyField(_sizeX); EditorGUILayout.PropertyField(_sizeZ); EditorGUILayout.PropertyField(_cellSize); EditorGUILayout.PropertyField(_lowerBoundary); EditorGUILayout.PropertyField(_upperBoundary); EditorGUILayout.PropertyField(_obstacleSensitivityRange); EditorGUILayout.PropertyField(_obstacleAndGroundDetection); EditorUtilities.Section("Subsections"); EditorGUILayout.PropertyField(_subSectionsX); EditorGUILayout.PropertyField(_subSectionsZ); EditorGUILayout.PropertyField(_subSectionsCellOverlap); ShowHeightMapOptions(); EditorUtilities.Section("Initialization"); EditorGUILayout.PropertyField(_automaticInitialization); EditorGUILayout.PropertyField(_automaticConnections); if (_automaticConnections.boolValue) { EditorGUILayout.PropertyField(_connectorPortalWidth); } EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_storeBakedDataAsAsset); this.serializedObject.ApplyModifiedProperties(); if (GUILayout.Button(new GUIContent("Bake Grid", "Calculates grid data such as blocked areas and height map and stores this snapshot. The snapshot is then used to initialize the grid at runtime.\nPlease note that baking is completely optional."))) { foreach (var o in editedObjects) { var g = o as GridComponent; BakeGrid(g); } } GUI.enabled = true; }
public override void OnInspectorGUI() { if (Application.isPlaying) { EditorGUILayout.HelpBox("These settings cannot be edited in play mode.", MessageType.Info); return; } this.serializedObject.Update(); int baked = 0; var editedObjects = this.serializedObject.targetObjects; for (int i = 0; i < editedObjects.Length; i++) { var g = editedObjects[i] as GridComponent; if (g.bakedData != null) { baked++; } } EditorGUILayout.Separator(); if (baked > 0 && baked < editedObjects.Length) { EditorGUILayout.LabelField("A mix of baked and unbaked grids cannot be edited at the same time."); return; } //If data is baked, only offer an option to edit or rebake if (baked == editedObjects.Length) { EditorGUILayout.LabelField("The grid has been baked. To change it press the Edit button below."); GUILayout.BeginHorizontal(); if (GUILayout.Button("Edit")) { foreach (var o in editedObjects) { var g = o as GridComponent; EditorUtilities.RemoveAsset(g.bakedData); g.bakedData = null; g.ResetGrid(); EditorUtility.SetDirty(g); } } if (GUILayout.Button("Re-bake Grid")) { foreach (var o in editedObjects) { var g = o as GridComponent; BakeGrid(g); } } GUILayout.EndHorizontal(); return; } EditorGUILayout.PropertyField(_friendlyName, new GUIContent("Friendly Name", "An optional friendly name for the grid that will be used in messages and such.")); EditorUtilities.Section("Layout"); EditorGUILayout.PropertyField(_linkOriginToTransform, new GUIContent("Link Origin to Transform", "Link the center of the grid to the position of the game object.")); if (!_linkOriginToTransform.hasMultipleDifferentValues) { if (_linkOriginToTransform.boolValue) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_originOffset, new GUIContent("Offset", "The offset in relation to the linked transform."), true); EditorGUI.indentLevel--; } else { EditorGUILayout.PropertyField(_origin, new GUIContent("Origin", "The center of the grid."), true); } } EditorGUILayout.PropertyField(_sizeX, new GUIContent("Size X", "Number of cells along the x-axis.")); EditorGUILayout.PropertyField(_sizeZ, new GUIContent("Size Z", "Number of cells along the z-axis.")); EditorGUILayout.PropertyField(_cellSize, new GUIContent("Cell Size", "The size of each grid cell, expressed as the length of one side.")); EditorGUILayout.PropertyField(_lowerBoundary, new GUIContent("Lower Boundary", "How far below the grid's plane does the grid have influence.")); EditorGUILayout.PropertyField(_upperBoundary, new GUIContent("Upper Boundary", "How far above the grid's plane does the grid have influence.")); EditorGUILayout.PropertyField(_obstacleSensitivityRange, new GUIContent("Obstacle Sensitivity Range", "How close to the center of a cell must an obstacle be to block the cell.")); EditorGUILayout.PropertyField(_obstacleAndGroundDetection, new GUIContent("Obstacle and Ground Detection", "Controls the method used to detect terrain and obstacles. Choose whichever works for your type of terrain.")); EditorUtilities.Section("Subsections"); EditorGUILayout.PropertyField(_subSectionsX, new GUIContent("Subsections X", "Number of subsections along the x-axis.")); EditorGUILayout.PropertyField(_subSectionsZ, new GUIContent("Subsections Z", "Number of subsections along the z-axis.")); EditorGUILayout.PropertyField(_subSectionsCellOverlap, new GUIContent("Subsections Cell Overlap", "The number of cells by which subsections overlap neighbouring subsections.")); ShowHeightMapOptions(); EditorUtilities.Section("Initialization"); EditorGUILayout.PropertyField(_automaticInitialization, new GUIContent("Automatic Initialization", "Controls whether the grid is automatically initialized when enabled. If unchecked the grid must be manually initialized.")); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_storeBakedDataAsAsset, new GUIContent("Store Grid data as asset", "Store baked data in a separate asset file instead of storing to the scene, this enables prefab'ing.")); this.serializedObject.ApplyModifiedProperties(); if (GUILayout.Button("Bake Grid")) { foreach (var o in editedObjects) { var g = o as GridComponent; BakeGrid(g); } } }
private void OnGUI() { var rect = EditorGUILayout.BeginVertical(GUILayout.Width(400), GUILayout.Height(400)); EditorGUIUtility.labelWidth = 200f; EditorGUILayout.HelpBox("This tool allows you to easily generate a grid field, that is a number of grids stitched together in order to cover a large scene", MessageType.Info); EditorGUILayout.Separator(); EditorUtilities.Section("Field"); _fieldSizeX = EditorGUILayout.IntField(new GUIContent("Grids along x-axis", "Number of grids along the x-axis."), _fieldSizeX); _fieldSizeZ = EditorGUILayout.IntField(new GUIContent("Grids along z-axis", "Number of grids along the x-axis."), _fieldSizeZ); _disableAutoInit = EditorGUILayout.Toggle(new GUIContent("Disable Automatic Initialization", "Sets the grid's automatic initialization setting to false."), _disableAutoInit); EditorGUILayout.Separator(); _friendlyName = EditorGUILayout.TextField(new GUIContent("Grid Base Name", "An optional friendly name for the grids, each grid will also get a number post fix."), _friendlyName); EditorUtilities.Section("Layout"); _sizeX = EditorGUILayout.IntField(new GUIContent("Size X", "Number of cells along the x-axis."), _sizeX); _sizeZ = EditorGUILayout.IntField(new GUIContent("Size Z", "Number of cells along the z-axis."), _sizeZ); _cellSize = EditorGUILayout.FloatField(new GUIContent("Cell Size", "The size of each grid cell, expressed as the length of one side."), _cellSize); _lowerBoundary = EditorGUILayout.FloatField(new GUIContent("Lower Boundary", "How far below the grid's plane does the grid have influence."), _lowerBoundary); _upperBoundary = EditorGUILayout.FloatField(new GUIContent("Upper Boundary", "How far above the grid's plane does the grid have influence."), _upperBoundary); _obstacleSensitivityRange = EditorGUILayout.FloatField(new GUIContent("Obstacle Sensitivity Range", "How close to the center of a cell must an obstacle be to block the cell."), _obstacleSensitivityRange); if (_obstacleSensitivityRange > (_cellSize / 2.0f)) { _obstacleSensitivityRange = _cellSize / 2.0f; } EditorUtilities.Section("Subsections"); EditorGUILayout.IntField(new GUIContent("Subsections X", "Number of subsections along the x-axis."), _subSectionsX); _subSectionsZ = EditorGUILayout.IntField(new GUIContent("Subsections Z", "Number of subsections along the z-axis."), _subSectionsZ); _subSectionsCellOverlap = EditorGUILayout.IntField(new GUIContent("Subsections Cell Overlap", "The number of cells by which subsections overlap neighbouring subsections."), _subSectionsCellOverlap); EditorGUI.indentLevel -= 1; EditorGUILayout.Separator(); _generateHeightMap = EditorGUILayout.Toggle(new GUIContent("Generate Height Map", "Controls whether the grid generates a height map to allow height sensitive navigation."), _generateHeightMap); EditorGUI.indentLevel += 1; if (_generateHeightMap) { _heightLookupType = (HeightLookupType)EditorGUILayout.EnumPopup(new GUIContent("Lookup Type", "Dictionaries are fast but dense. Quad Trees are sparse but slower and are very dependent on height distributions. Use Quad trees on maps with large same height areas."), _heightLookupType); if (_heightLookupType == HeightLookupType.QuadTree) { _heightLookupMaxDepth = EditorGUILayout.IntField(new GUIContent("Tree Depth", "The higher the allowed depth, the more sparse the tree will be but it will also get slower."), _heightLookupMaxDepth); } } EditorGUILayout.Separator(); if (GUILayout.Button("Create Grid Field")) { CreateGridField(); this.Close(); } EditorGUILayout.Separator(); EditorGUIUtility.labelWidth = 0f; EditorGUILayout.EndVertical(); this.minSize = new Vector2(rect.width, rect.height); }