/// <summary> Gets or sets the type of agent that can use the link. </summary>
publicintagentTypeID
{
get=>m_AgentTypeID;
set
{
if(value==m_AgentTypeID)
return;
m_AgentTypeID=value;
UpdateLink();
}
}
/// <summary> Gets or sets the local position at the middle of the link's start edge, relative to the GameObject origin. </summary>
/// <remarks> This property determines the position of the link's start edge only when <see cref="startTransform"/> is `null`. Otherwise, it is the `startTransform` that determines the edge's position. <br/>
/// The world scale of the GameObject is never used.</remarks>
publicVector3startPoint
{
get=>m_StartPoint;
set
{
if(value==m_StartPoint)
return;
m_StartPoint=value;
UpdateLink();
}
}
/// <summary> Gets or sets the local position at the middle of the link's end edge, relative to the GameObject origin. </summary>
/// <remarks> This property determines the position of the link's end edge only when <see cref="endTransform"/> is `null`. Otherwise, it is the `endTransform` that determines the edge's position. <br/>
/// The world scale of the GameObject is never used.</remarks>
publicVector3endPoint
{
get=>m_EndPoint;
set
{
if(value==m_EndPoint)
return;
m_EndPoint=value;
UpdateLink();
}
}
/// <summary> Gets or sets the <see cref="Transform"/> tracked by the middle of the link's start edge. </summary>
/// <remarks> The link places the start edge at the world position of the object referenced by this property. In that case <see cref="startPoint"/> is not used. Otherwise, when this property is `null`, the component applies the GameObject's translation and rotation as a transform to <see cref="startPoint"/> in order to establish the world position of the link's start edge. </remarks>
publicTransformstartTransform
{
get=>m_StartTransform;
set
{
if(value==m_StartTransform)
return;
m_StartTransform=value;
UpdateLink();
}
}
/// <summary> Gets or sets the <see cref="Transform"/> tracked by the middle of the link's end edge. </summary>
/// <remarks> The link places the end edge at the world position of the object referenced by this property. In that case <see cref="endPoint"/> is not used. Otherwise, when this property is `null`, the component applies the GameObject's translation and rotation as a transform to <see cref="endPoint"/> in order to establish the world position of the link's end edge. </remarks>
publicTransformendTransform
{
get=>m_EndTransform;
set
{
if(value==m_EndTransform)
return;
m_EndTransform=value;
UpdateLink();
}
}
/// <summary> The width of the segments making up the ends of the link. </summary>
/// <remarks> The segments are created perpendicular to the line from start to end, in the XZ plane of the GameObject. </remarks>
publicfloatwidth
{
get=>m_Width;
set
{
if(value.Equals(m_Width))
return;
m_Width=value;
UpdateLink();
}
}
/// <summary> Gets or sets a value that determines the cost of traversing the link.</summary>
/// <remarks> A negative value implies that the cost of traversing the link is obtained based on the area type.<br/>
/// A positive or zero value overrides the cost associated with the area type.</remarks>
/// <summary> Gets or sets whether agents can traverse the link in both directions. </summary>
/// <remarks> When a link connects to NavMeshes at both ends, agents can always traverse that link from the start position to the end position. When this property is set to `true` it allows the agents to traverse the link from the end position to the start position as well. When the value is `false` the agents will not traverse the link from the end position to the start position. </remarks>
publicboolbidirectional
{
get=>m_Bidirectional;
set
{
if(value==m_Bidirectional)
return;
m_Bidirectional=value;
UpdateLink();
}
}
/// <summary> Gets or sets whether the world positions of the link's edges update whenever
/// the GameObject transform, the <see cref="startTransform"/> or the <see cref="endTransform"/> change at runtime. </summary>
publicboolautoUpdate
{
get=>m_AutoUpdatePosition;
set
{
if(value==m_AutoUpdatePosition)
return;
m_AutoUpdatePosition=value;
if(m_AutoUpdatePosition)
AddTracking(this);
else
RemoveTracking(this);
}
}
/// <summary> The area type of the link. </summary>
publicintarea
{
get=>m_Area;
set
{
if(value==m_Area)
return;
m_Area=value;
UpdateLink();
}
}
/// <summary> Gets or sets whether the link can be traversed by agents. </summary>
/// <remarks> When this property is set to `true` it allows the agents to traverse the link. When the value is `false` no paths pass through this link and no agent can traverse it as part of their autonomous movement. </remarks>
/// <summary> Replaces the link with a new one using the current settings. </summary>
publicvoidUpdateLink()
{
if(!isActiveAndEnabled)
return;
NavMesh.RemoveLink(m_LinkInstance);
AddLink();
}
staticvoidAddTracking(NavMeshLinklink)
{
#ifUNITY_EDITOR
if(s_Tracked.Contains(link))
{
Debug.LogError("Link is already tracked: "+link);
return;
}
#endif
if(s_Tracked.Count==0)
NavMesh.onPreUpdate+=UpdateTrackedInstances;
s_Tracked.Add(link);
link.RecordEndpointTransforms();
}
staticvoidRemoveTracking(NavMeshLinklink)
{
s_Tracked.Remove(link);
if(s_Tracked.Count==0)
NavMesh.onPreUpdate-=UpdateTrackedInstances;
}
/// <summary>Gets the world positions of the start and end points for the link.</summary>
/// <param name="worldStartPosition">Returns the world position of <see cref="startTransform"/> if it is not <c>null</c>; otherwise, <see cref="startPoint"/> transformed into world space.</param>
/// <param name="worldEndPosition">Returns the world position of <see cref="endTransform"/> if it is not <c>null</c>; otherwise, <see cref="endPoint"/> transformed into world space.</param>
/// <summary>Gets the positions of the start and end points in the local space of the link.</summary>
/// <param name="localStartPosition">Returns the local position of <see cref="startTransform"/> if it is not <c>null</c>; otherwise, <see cref="startPoint"/>.</param>
/// <param name="localEndPosition">Returns the local position of <see cref="endTransform"/> if it is not <c>null</c>; otherwise, <see cref="endPoint"/>.</param>