Version: 5.4
public static int GetAreaFromName (string areaName);

パラメーター

areaName 検索するエリアの名前

戻り値

int 指定されていた場合はインデックス。エリアが見つからない場合は -1 。

説明

ナビメッシュのエリアタイプ名からインデックスを返します

// NearestPointOnWater.cs
using UnityEngine;
using System.Collections;
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.

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