docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NavMeshSurface

    Component used for building and enabling a NavMesh surface for one agent type.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    NavMeshSurface
    Inherited Members
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.destroyCancellationToken
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.GetComponentIndex()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, InstantiateParameters)
    Object.InstantiateAsync<T>(T, int, InstantiateParameters)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate<T>(T, InstantiateParameters)
    Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.AI.Navigation
    Assembly: Unity.AI.Navigation.dll
    Syntax
    [ExecuteAlways]
    [DefaultExecutionOrder(-102)]
    [AddComponentMenu("Navigation/NavMeshSurface", 30)]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.ai.navigation@1.1/manual/NavMeshSurface.html")]
    public class NavMeshSurface : MonoBehaviour

    Properties

    activeSurfaces

    Gets the list of all the NavMeshSurface components that are currently active in the scene.

    Declaration
    public static List<NavMeshSurface> activeSurfaces { get; }
    Property Value
    Type Description
    List<NavMeshSurface>

    agentTypeID

    Gets or sets the identifier of the agent type that will use this NavMesh Surface.

    Declaration
    public int agentTypeID { get; set; }
    Property Value
    Type Description
    int

    buildHeightMesh

    Gets or sets whether the NavMesh building process produces more detailed elevation information.

    Declaration
    public bool buildHeightMesh { get; set; }
    Property Value
    Type Description
    bool
    See Also
    https://docs.unity3d.com/Packages/com.unity.ai.navigation@1.0/manual/NavMeshSurface.html#advanced-settings

    center

    Gets or sets the center position of the volume that delimits the NavMesh created by this component.

    Declaration
    public Vector3 center { get; set; }
    Property Value
    Type Description
    Vector3
    Remarks

    It is used only when collectObjects is set to Volume. The position applies in the local space of the GameObject.

    collectObjects

    Gets or sets the method for retrieving the objects that will be used for baking.

    Declaration
    public CollectObjects collectObjects { get; set; }
    Property Value
    Type Description
    CollectObjects

    defaultArea

    Gets or sets the area type assigned to any object that does not have one specified.

    Declaration
    public int defaultArea { get; set; }
    Property Value
    Type Description
    int
    Remarks

    To customize the area type of an object add a NavMeshModifier component and set overrideArea to true. The area type information is used when baking the NavMesh.

    See Also
    https://docs.unity3d.com/Manual/nav-AreasAndCosts.html

    ignoreNavMeshAgent

    Gets or sets whether the process of building the NavMesh ignores the GameObjects containing a NavMeshAgent component.

    Declaration
    public bool ignoreNavMeshAgent { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    There is generally no need for the NavMesh to take into consideration the objects that can move.

    ignoreNavMeshObstacle

    Gets or sets whether the process of building the NavMesh ignores the GameObjects containing a NavMeshObstacle component.

    Declaration
    public bool ignoreNavMeshObstacle { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    There is generally no need for the NavMesh to take into consideration the objects that can move.

    layerMask

    Gets or sets a bitmask representing which layers to consider when selecting the objects that will be used for baking the NavMesh.

    Declaration
    public LayerMask layerMask { get; set; }
    Property Value
    Type Description
    LayerMask

    minRegionArea

    Gets or sets the minimum acceptable surface area of any continuous portion of the NavMesh.

    Declaration
    public float minRegionArea { get; set; }
    Property Value
    Type Description
    float
    Remarks

    This parameter is used only at the time when the NavMesh is getting built. It allows you to cull away any isolated NavMesh regions that are smaller than this value and that do not straddle or touch a tile boundary.

    navMeshData

    Gets or sets the reference to the NavMesh data instantiated by this surface.

    Declaration
    public NavMeshData navMeshData { get; set; }
    Property Value
    Type Description
    NavMeshData

    overrideTileSize

    Gets or sets whether the NavMesh building process uses the tileSize value.

    Declaration
    public bool overrideTileSize { get; set; }
    Property Value
    Type Description
    bool

    overrideVoxelSize

    Gets or sets whether the NavMesh building process uses the voxelSize value.

    Declaration
    public bool overrideVoxelSize { get; set; }
    Property Value
    Type Description
    bool

    size

    Gets or sets the size of the volume that delimits the NavMesh created by this component.

    Declaration
    public Vector3 size { get; set; }
    Property Value
    Type Description
    Vector3
    Remarks

    It is used only when collectObjects is set to Volume. The size applies in the local space of the GameObject.

    tileSize

    Gets or sets the width of the square grid of voxels that the NavMesh building process uses for sampling the scene geometry.

    Declaration
    public int tileSize { get; set; }
    Property Value
    Type Description
    int
    Remarks

    This value represents a number of voxels. Together with voxelSize it determines the real size of the individual sections that comprise the NavMesh.

    useGeometry

    Gets or sets which type of component in the GameObjects provides the geometry used for baking the NavMesh.

    Declaration
    public NavMeshCollectGeometry useGeometry { get; set; }
    Property Value
    Type Description
    NavMeshCollectGeometry

    voxelSize

    Gets or sets the width of the square voxels that the NavMesh building process uses for sampling the scene geometry.

    Declaration
    public float voxelSize { get; set; }
    Property Value
    Type Description
    float
    Remarks

    This value is in world units. Together with tileSize it determines the real size of the individual sections that comprise the NavMesh.

    Methods

    AddData()

    Creates an instance of the NavMesh data and activates it in the navigation system.

    Declaration
    public void AddData()
    Remarks

    The instance is created at the position and with the orientation of the GameObject.

    BuildNavMesh()

    Builds and instantiates this NavMesh surface.

    Declaration
    public void BuildNavMesh()

    GetBuildSettings()

    Retrieves a copy of the current settings chosen for building this NavMesh surface.

    Declaration
    public NavMeshBuildSettings GetBuildSettings()
    Returns
    Type Description
    NavMeshBuildSettings

    The settings configured in this NavMeshSurface.

    RemoveData()

    Removes the instance of this NavMesh data from the navigation system.

    Declaration
    public void RemoveData()
    Remarks

    This operation does not destroy the navMeshData.

    UpdateNavMesh(NavMeshData)

    Rebuilds parts of an existing NavMesh in the regions of the scene where the objects have changed.

    Declaration
    public AsyncOperation UpdateNavMesh(NavMeshData data)
    Parameters
    Type Name Description
    NavMeshData data

    The NavMesh to update according to the changes in the scene.

    Returns
    Type Description
    AsyncOperation

    A reference to the asynchronous coroutine that builds the NavMesh.

    Remarks

    This operation is executed asynchronously.


    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Properties
      • activeSurfaces
      • agentTypeID
      • buildHeightMesh
      • center
      • collectObjects
      • defaultArea
      • ignoreNavMeshAgent
      • ignoreNavMeshObstacle
      • layerMask
      • minRegionArea
      • navMeshData
      • overrideTileSize
      • overrideVoxelSize
      • size
      • tileSize
      • useGeometry
      • voxelSize
    • Methods
      • AddData()
      • BuildNavMesh()
      • GetBuildSettings()
      • RemoveData()
      • UpdateNavMesh(NavMeshData)
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)