Hi,
It’d be very nice to add more control over a graph’s importance volume using Handles. For example, I’ve added a box handle, rotation handle, and position handle for every recast graph
RecastGraphEditor:
private BoxBoundsHandle boxBoundsHandle = new();
public override void OnSceneGUI(NavGraph target)
{
base.OnSceneGUI(target);
var graph = target as RecastGraph;
if (!graph.drawGizmos)
return;
const float gizmosScale = .5f;
var gizmosMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * gizmosScale);
var currentRot = Quaternion.Euler(graph.rotation);
var position = graph.forcedBoundsCenter;
using (new Handles.DrawingScope(gizmosMatrix))
{
EditorGUI.BeginChangeCheck();
position /= gizmosScale;
Handles.TransformHandle(ref position, ref currentRot);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(target.active, "Changed transform");
graph.rotation = currentRot.eulerAngles;
graph.forcedBoundsCenter = position * gizmosScale;
}
}
var matrix = Matrix4x4.TRS(Vector3.zero, currentRot, Vector3.one);
boxBoundsHandle.size = graph.forcedBoundsSize;
boxBoundsHandle.center = matrix.inverse * graph.forcedBoundsCenter;
using (new Handles.DrawingScope(matrix))
{
EditorGUI.BeginChangeCheck();
boxBoundsHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(target.active, "Changed bounds");
graph.forcedBoundsSize = boxBoundsHandle.size;
graph.forcedBoundsCenter = matrix * boxBoundsHandle.center;
}
}
}
and also hide the default transform gizmos for the AstarPath object as it doesn’t do anything. AstarPathEditor
public void OnEnable() {
Tools.hidden = true; // hide default transform gizmos when selected
/// rest of code
}
public void OnDisable() {
Tools.hidden = false; // show default transform gizmos when deselected
/// rest of code
}
Hope it helps,
Cheers!