How to know the area name that agent is stepping?

The agent go by many areas, like walkable, street, etc. How can I know the area it is currently stepping?

Use the NavMeshAgent.SamplePathPosition api:

// SampleGround.cs
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

[RequireComponent (typeof (NavMeshAgent))]
public class SampleGround : MonoBehaviour {
   NavMeshAgent agent;
   NavMeshHit hit = new NavMeshHit();

   void Start () {
     agent = GetComponent<NavMeshAgent> ();   
   }
   
   void Update () {
     // sample directly under agent
     agent.SamplePathPosition(NavMesh.AllAreas, 0.0f, out hit);
     Debug.Log ("Agent is currently on " + hit.mask);

#if UNITY_EDITOR
     // in editor show the name too
     var names = GameObjectUtility.GetNavMeshAreaNames ();
     for (var i = 0; i < names.Length; ++i)
     {
       int mask = 1 << NavMesh.GetAreaFromName(names[i]);
       if ((hit.mask & mask) != 0)
       {
         Debug.Log (".. that's \"" + names[i] + "\"");
       }
     }
#endif
   }
}