public static int GetAreaFromName (string areaName);

파라미터

areaNameName of the area to look up.

반환

int Index if the specified are, or -1 if no area found.

설명

Returns the area index for a named NavMesh area type.

// NearestPointOnWater
using UnityEngine;
using UnityEngine.AI;

public class NearestPointOnWater : MonoBehaviour { void Update() { // Find nearest point on water. int waterMask = 1 << NavMesh.GetAreaFromName("water"); NavMeshHit hit; if (NavMesh.SamplePosition(transform.position, out hit, 2.0f, waterMask)) { Debug.DrawRay(hit.position, Vector3.up, Color.blue); } } }

See Also: Areas and Costs to learn how to use different Area types.