Version: 2021.1
언어: 한국어

NavMesh.GetAreaFromName

매뉴얼로 전환
public static int GetAreaFromName (string areaName);

파라미터

areaName Name 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 the 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.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961