---
tags:
    - "Navigation, NavMesh, AI, Pathfinding, Agent"
---

# Nav Mesh Agent Get Area Cost

[Navigation](../index.md) / [Nav Mesh Agent](index.md) / **Nav Mesh Agent Get Area Cost**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Returns the execution of Get Area Cost method on the Nav Mesh Agent component

## Code

```cs
// <auto-generated>
// This script was automatically generated using the Visual Script Transpiler.
// Do not modify. Changes to this file will be lost when updating the package.
// </auto-generated>

using System;
using UnityEngine;
using VisualScript.Icons;
using UnityEngine.AI;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Nav Mesh Agent Get Area Cost")]
    [Category("Navigation/Nav Mesh Agent/Get Area Cost")]
    [Description("Returns the execution of Get Area Cost method on the Nav Mesh Agent component")]

    [Image(typeof(IconNavmeshAgent), ColorTheme.Type.Red)]
    [Keywords("Navigation, NavMesh, AI, Pathfinding, Agent")]

    [Serializable]
    public class GenTypeNumber_NavMeshAgent_GetAreaCost_1 : TypeNumber
    {
        [SerializeField] private GetGameObject m_NavMeshAgent = new GetGameObject(
            new GenTypeGameObject_NavMeshAgent()
        );

        [SerializeField] private GetInteger m_AreaIndex = new GetInteger();

        public override double Get(Args args)
        {
            NavMeshAgent component = this.m_NavMeshAgent.Get<NavMeshAgent>(args);
            if (component == null) return default;

            double value = (double) component.GetAreaCost(
                (int) this.m_AreaIndex.Get(args)
            );

            return value;
        }

        public override string ToString()
        {
            return $"{this.m_NavMeshAgent} Get Area Cost ({this.m_AreaIndex})";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
```

