您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
39 行
1.5 KiB
39 行
1.5 KiB
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
using UnityEngine.Assertions;
|
|
|
|
namespace Unity.Multiplayer.Samples.BossRoom.Server
|
|
{
|
|
[DefaultExecutionOrder(10000)] // The enable/disable triggers have to be called after the triggers from NavMeshObstacle which update the nav mesh.
|
|
[RequireComponent(typeof(NavMeshObstacle))]
|
|
public sealed class DynamicNavObstacle : MonoBehaviour
|
|
{
|
|
private NavigationSystem m_NavigationSystem;
|
|
|
|
private void Awake()
|
|
{
|
|
m_NavigationSystem = GameObject.FindGameObjectWithTag(NavigationSystem.NavigationSystemTag).GetComponent<NavigationSystem>();
|
|
}
|
|
|
|
private void OnValidate()
|
|
{
|
|
if (gameObject.scene.rootCount > 1) // Hacky way for checking if this is a scene object or a prefab instance and not a prefab definition.
|
|
{
|
|
Assert.IsNotNull(
|
|
GameObject.FindGameObjectWithTag(NavigationSystem.NavigationSystemTag)?.GetComponent<NavigationSystem>(),
|
|
$"NavigationSystem not found. Is there a NavigationSystem Behaviour in the Scene and does its GameObject have the {NavigationSystem.NavigationSystemTag} tag?"
|
|
);
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
m_NavigationSystem.OnDynamicObstacleEnabled();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
m_NavigationSystem.OnDynamicObstacleDisabled();
|
|
}
|
|
}
|
|
}
|