I wrote it myself, but basically I use the API.
...
if (isXZ)
{
newPos = curNode.ClosestPointOnNodeXZ(endPos);
newPos.y = endPos.y;
}
else
{
newPos = curNode.ClosestPointOnNode(endPos);
}
...
NNConstraint contraint;
if (isXZ)
{
contraint = NavmeshConstant.CONSTRAINT_XZ;
}
else
{
contraint = NavmeshConstant.CONSTRAINT_NONE;
}
NNInfo info = AstarPath.active.GetNearest(pos, contraint);
...