summaryrefslogtreecommitdiff
path: root/Runtime/NavMesh/ScriptBindings
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/NavMesh/ScriptBindings')
-rw-r--r--Runtime/NavMesh/ScriptBindings/NavMeshAgentBindings.txt263
-rw-r--r--Runtime/NavMesh/ScriptBindings/NavMeshBindings.txt265
-rw-r--r--Runtime/NavMesh/ScriptBindings/NavMeshObstacleBindings.txt40
-rw-r--r--Runtime/NavMesh/ScriptBindings/NavMeshPathBindings.txt133
4 files changed, 701 insertions, 0 deletions
diff --git a/Runtime/NavMesh/ScriptBindings/NavMeshAgentBindings.txt b/Runtime/NavMesh/ScriptBindings/NavMeshAgentBindings.txt
new file mode 100644
index 0000000..973c4b3
--- /dev/null
+++ b/Runtime/NavMesh/ScriptBindings/NavMeshAgentBindings.txt
@@ -0,0 +1,263 @@
+C++RAW
+#include "UnityPrefix.h"
+#include "Configuration/UnityConfigure.h"
+#include "Runtime/Mono/MonoManager.h"
+#include "Runtime/Mono/MonoBehaviour.h"
+#include "Runtime/NavMesh/NavMesh.h"
+#include "Runtime/NavMesh/NavMeshAgent.h"
+#include "Runtime/NavMesh/OffMeshLink.h"
+#include "Runtime/Scripting/ScriptingUtility.h"
+#include "Runtime/Scripting/ScriptingExportUtility.h"
+
+CSRAW
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace UnityEngine
+{
+
+// Keep this enum in sync with the one defined in "NavMeshTypes.h"
+ENUM ObstacleAvoidanceType
+ // Disable avoidance.
+ NoObstacleAvoidance = 0,
+
+ // Enable simple avoidance. Low performance impact.
+ LowQualityObstacleAvoidance = 1,
+
+ // Medium avoidance. Medium performance impact
+ MedQualityObstacleAvoidance = 2,
+
+ // Good avoidance. High performance impact
+ GoodQualityObstacleAvoidance = 3,
+
+ // Enable highest precision. Highest performance impact.
+ HighQualityObstacleAvoidance = 4
+END
+
+
+
+// Navigation mesh agent.
+CLASS NavMeshAgent : Behaviour
+
+ // Sets or updates the destination. This triggers calculation for a new path.
+ CUSTOM bool SetDestination (Vector3 target)
+ {
+ return self->SetDestination (target);
+ }
+
+ // Destination to navigate towards.
+ AUTO_PROP Vector3 destination GetDestination SetDestination
+
+ // Stop within this distance from the target position.
+ AUTO_PROP float stoppingDistance GetStoppingDistance SetStoppingDistance
+
+ // The current velocity of the [[NavMeshAgent]] component.
+ AUTO_PROP Vector3 velocity GetVelocity SetVelocity
+
+ // The next position on the path.
+ AUTO_PROP Vector3 nextPosition GetNextPosition SetInternalAgentPosition
+
+ // The current steering target - usually the next corner or end point of the current path. (RO)
+ AUTO_PROP Vector3 steeringTarget GetNextCorner
+
+ // The desired velocity of the agent including any potential contribution from avoidance. (RO)
+ AUTO_PROP Vector3 desiredVelocity GetDesiredVelocity
+
+ // Remaining distance along the current path - or infinity when not known. (RO)
+ AUTO_PROP float remainingDistance GetRemainingDistance
+
+ // The relative vertical displacement of the owning [[GameObject]].
+ AUTO_PROP float baseOffset GetBaseOffset SetBaseOffset
+
+ // Is agent currently positioned on an OffMeshLink. (RO)
+ CUSTOM_PROP bool isOnOffMeshLink
+ {
+ return self->IsOnOffMeshLink ();
+ }
+
+ // Enables or disables the current link.
+ CUSTOM void ActivateCurrentOffMeshLink (bool activated)
+ {
+ return self->ActivateCurrentOffMeshLink (activated);
+ }
+
+ // The current [[OffMeshLinkData]].
+ CSRAW public OffMeshLinkData currentOffMeshLinkData { get { return GetCurrentOffMeshLinkDataInternal (); } }
+
+ CUSTOM internal OffMeshLinkData GetCurrentOffMeshLinkDataInternal ()
+ {
+ OffMeshLinkData data;
+ self->GetCurrentOffMeshLinkData (&data);
+ return data;
+ }
+
+ // The next [[OffMeshLinkData]] on the current path.
+ CSRAW public OffMeshLinkData nextOffMeshLinkData { get { return GetNextOffMeshLinkDataInternal (); } }
+
+ CUSTOM internal OffMeshLinkData GetNextOffMeshLinkDataInternal ()
+ {
+ OffMeshLinkData data;
+ self->GetNextOffMeshLinkData (&data);
+ return data;
+ }
+
+ // Terminate OffMeshLink occupation and transfer the agent to the closest point on other side.
+ CUSTOM void CompleteOffMeshLink ()
+ {
+ return self->CompleteOffMeshLink ();
+ }
+
+ // Automate movement onto and off of OffMeshLinks.
+ AUTO_PROP bool autoTraverseOffMeshLink GetAutoTraverseOffMeshLink SetAutoTraverseOffMeshLink
+
+ // Automate braking of NavMeshAgent to avoid overshooting the destination.
+ AUTO_PROP bool autoBraking GetAutoBraking SetAutoBraking
+
+ // Attempt to acquire a new path if the existing path becomes invalid
+ AUTO_PROP bool autoRepath GetAutoRepath SetAutoRepath
+
+ // Does this agent currently have a path. (RO)
+ AUTO_PROP bool hasPath HasPath
+
+ // A path is being computed, but not yet ready. (RO)
+ AUTO_PROP bool pathPending PathPending
+
+ // Is the current path stale. (RO)
+ AUTO_PROP bool isPathStale IsPathStale
+
+ // Query the state of the current path.
+ AUTO_PROP NavMeshPathStatus pathStatus GetPathStatus
+
+ //*undocumented*
+ AUTO_PROP Vector3 pathEndPosition GetEndPositionOfCurrentPath
+
+ //*undocumented*
+ CUSTOM bool Warp (Vector3 newPosition)
+ {
+ return self->Warp(newPosition);
+ }
+
+ // Apply relative movement to current position.
+ CUSTOM void Move (Vector3 offset)
+ {
+ return self->Move (offset);
+ }
+
+ // Stop movement of this agent along its current path.
+ CUSTOM void Stop (bool stopUpdates = false)
+ {
+ return self->Stop (stopUpdates);
+ }
+
+ // Resumes the movement along the current path.
+ CUSTOM void Resume ()
+ {
+ return self->Resume ();
+ }
+
+ // Clears the current path. Note that this agent will not start looking for a new path until SetDestination is called.
+ CUSTOM void ResetPath ()
+ {
+ return self->ResetPath ();
+ }
+
+ // Assign path to this agent.
+ CUSTOM bool SetPath (NavMeshPath path)
+ {
+ Scripting::RaiseIfNull (path);
+ MonoNavMeshPath monopath;
+ MarshallManagedStructIntoNative (path, &monopath);
+ return self->SetPath (monopath.native);
+ }
+
+ // Set or get a copy of the current path.
+ CSRAW public NavMeshPath path { get { NavMeshPath path = new NavMeshPath (); CopyPathTo (path); return path; } set { if(value==null) throw new NullReferenceException(); SetPath (value); } }
+
+ CUSTOM internal void CopyPathTo (NavMeshPath path)
+ {
+ Scripting::RaiseIfNull (path);
+ MonoNavMeshPath monopath;
+ MarshallManagedStructIntoNative (path, &monopath);
+ self->CopyPath (monopath.native);
+ }
+
+ // Locate the closest NavMesh edge.
+ CUSTOM bool FindClosestEdge (out NavMeshHit hit)
+ {
+ return self->DistanceToEdge (hit);
+ }
+
+ // Trace movement towards a target postion in the NavMesh. Without moving the agent.
+ CUSTOM bool Raycast (Vector3 targetPosition, out NavMeshHit hit)
+ {
+ return self->Raycast (targetPosition, hit);
+ }
+
+ // Calculate a path to a specified point and store the resulting path.
+ CSRAW public bool CalculatePath (Vector3 targetPosition, NavMeshPath path)
+ {
+ path.ClearCorners ();
+ return CalculatePathInternal (targetPosition, path);
+ }
+
+ CUSTOM private bool CalculatePathInternal (Vector3 targetPosition, NavMeshPath path)
+ {
+ MonoNavMeshPath monopath;
+ MarshallManagedStructIntoNative (path, &monopath);
+ int actualSize = self->CalculatePolygonPath (targetPosition, monopath.native);
+ return actualSize>0;
+ }
+
+ // Sample a position along the current path.
+ CUSTOM bool SamplePathPosition (int passableMask, float maxDistance, out NavMeshHit hit)
+ {
+ return self->SamplePathPosition (passableMask, maxDistance, hit);
+ }
+
+ // Sets the cost for traversing over geometry of the layer type.
+ CUSTOM void SetLayerCost (int layer, float cost)
+ {
+ self->SetLayerCost (layer, cost);
+ }
+
+ // Gets the cost for traversing over geometry of the layer type.
+ CUSTOM float GetLayerCost (int layer)
+ {
+ return self->GetLayerCost (layer);
+ }
+
+ // Specifies which NavMesh layers are passable (bitfield). Changing /walkableMask/ will make the path stale (see ::ref::isPathStale)
+ AUTO_PROP int walkableMask GetWalkableMask SetWalkableMask
+
+ // Maximum movement speed.
+ AUTO_PROP float speed GetSpeed SetSpeed
+
+ // Maximum rotation speed in (deg/s).
+ AUTO_PROP float angularSpeed GetAngularSpeed SetAngularSpeed
+
+ // Maximum acceleration.
+ AUTO_PROP float acceleration GetAcceleration SetAcceleration
+
+ // Should the agent update the transform position.
+ AUTO_PROP bool updatePosition GetUpdatePosition SetUpdatePosition
+
+ // Should the agent update the transform orientation.
+ AUTO_PROP bool updateRotation GetUpdateRotation SetUpdateRotation
+
+ // Agent avoidance radius.
+ AUTO_PROP float radius GetRadius SetRadius
+
+ // Agent height.
+ AUTO_PROP float height GetHeight SetHeight
+
+ // The level of quality of avoidance.
+ AUTO_PROP ObstacleAvoidanceType obstacleAvoidanceType GetObstacleAvoidanceType SetObstacleAvoidanceType
+
+ // The avoidance priority level.
+ AUTO_PROP int avoidancePriority GetAvoidancePriority SetAvoidancePriority
+END
+
+CSRAW }
+
diff --git a/Runtime/NavMesh/ScriptBindings/NavMeshBindings.txt b/Runtime/NavMesh/ScriptBindings/NavMeshBindings.txt
new file mode 100644
index 0000000..5757557
--- /dev/null
+++ b/Runtime/NavMesh/ScriptBindings/NavMeshBindings.txt
@@ -0,0 +1,265 @@
+C++RAW
+
+#include "UnityPrefix.h"
+#include "Configuration/UnityConfigure.h"
+#include "Runtime/Mono/MonoManager.h"
+#include "Runtime/Mono/MonoBehaviour.h"
+#include "Runtime/NavMesh/NavMesh.h"
+#include "Runtime/NavMesh/NavMeshAgent.h"
+#include "Runtime/NavMesh/OffMeshLink.h"
+#include "Runtime/NavMesh/NavMeshSettings.h"
+#include "Runtime/NavMesh/NavMeshLayers.h"
+#include "Runtime/Scripting/ScriptingUtility.h"
+#include "Runtime/Scripting/ScriptingExportUtility.h"
+#include "Runtime/Scripting/Backend/ScriptingTypeRegistry.h"
+#include "Runtime/Scripting/Backend/ScriptingBackendApi.h"
+#include "External/Recast/Detour/Include/DetourNavMeshQuery.h"
+#include "Runtime/Scripting/Scripting.h"
+
+CSRAW
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace UnityEngine
+{
+
+// Keep this enum in sync with the one defined in "NavMeshTypes.h"
+// Link type specifier.
+ENUM OffMeshLinkType
+
+ // Manually specified type of link.
+ LinkTypeManual = 0,
+
+ // Vertical drop.
+ LinkTypeDropDown = 1,
+
+ // Horizontal jump.
+ LinkTypeJumpAcross = 2
+END
+
+// Keep this struct in sync with the one defined in "NavMeshTypes.h"
+// State of OffMeshLink.
+STRUCT OffMeshLinkData
+ CSRAW private int m_Valid;
+ CSRAW private int m_Activated;
+ CSRAW private int m_InstanceID;
+ CSRAW private OffMeshLinkType m_LinkType;
+ CSRAW private Vector3 m_StartPos;
+ CSRAW private Vector3 m_EndPos;
+
+ // Is link valid (RO).
+ CSRAW public bool valid { get { return m_Valid != 0; } }
+
+ // Is link active (RO).
+ CSRAW public bool activated { get { return m_Activated != 0; } }
+
+ // Link type specifier (RO).
+ CSRAW public OffMeshLinkType linkType { get { return m_LinkType; } }
+
+ // Link start world position (RO).
+ CSRAW public Vector3 startPos { get { return m_StartPos; } }
+
+ // Link end world position (RO).
+ CSRAW public Vector3 endPos { get { return m_EndPos; } }
+
+ // The [[OffMeshLink]] if the link type is a manually placed Offmeshlink (RO).
+ CSRAW public OffMeshLink offMeshLink { get { return GetOffMeshLinkInternal (m_InstanceID); } }
+
+ CUSTOM internal OffMeshLink GetOffMeshLinkInternal (int instanceID)
+ {
+ return Scripting::ScriptingWrapperFor (dynamic_instanceID_cast<OffMeshLink*> (instanceID));
+ }
+
+END
+
+// Keep this struct in sync with the one defined in "NavMeshTypes.h"
+// Result information for NavMesh queries.
+STRUCT NavMeshHit
+ CSRAW private Vector3 m_Position;
+ CSRAW private Vector3 m_Normal;
+ CSRAW private float m_Distance;
+ CSRAW private int m_Mask;
+ CSRAW private int m_Hit;
+
+ // Position of hit.
+ CSRAW public Vector3 position { get { return m_Position; } set { m_Position = value; } }
+
+ // Normal at the point of hit.
+ CSRAW public Vector3 normal { get { return m_Normal; } set { m_Normal = value; } }
+
+ // Distance to the point of hit.
+ CSRAW public float distance { get { return m_Distance; } set { m_Distance = value; } }
+
+ // Mask specifying NavMeshLayers at point of hit.
+ CSRAW public int mask { get { return m_Mask; } set { m_Mask = value; } }
+
+ // Flag set when hit.
+ CSRAW public bool hit { get { return m_Hit != 0; } set { m_Hit = value ? 1 : 0; } }
+END
+
+
+// Contains data describing a triangulation of the navmesh
+STRUCT NavMeshTriangulation
+ CSRAW public Vector3[] vertices;
+ CSRAW public int[] indices;
+ CSRAW public int[] layers;
+END
+
+
+// Navigation mesh.
+CLASS NavMesh : Object
+
+ // Trace a ray between two points on the NavMesh.
+ CUSTOM static bool Raycast (Vector3 sourcePosition, Vector3 targetPosition, out NavMeshHit hit, int passableMask)
+ {
+ NavMesh* navMesh = GetNavMeshSettings ().GetNavMesh ();
+ if (navMesh == NULL) {
+ InvalidateNavMeshHit (hit);
+ return false;
+ }
+ const dtQueryFilter filter = dtQueryFilter::createFilterForIncludeFlags (passableMask);
+ return navMesh->Raycast (hit, sourcePosition, targetPosition, filter);
+ }
+
+ // Calculate a path between two points and store the resulting path.
+ CSRAW public static bool CalculatePath (Vector3 sourcePosition, Vector3 targetPosition, int passableMask, NavMeshPath path)
+ {
+ path.ClearCorners ();
+ return CalculatePathInternal (sourcePosition, targetPosition, passableMask, path);
+ }
+
+ CUSTOM internal private static bool CalculatePathInternal (Vector3 sourcePosition, Vector3 targetPosition, int passableMask, NavMeshPath path)
+ {
+ NavMesh* navMesh = GetNavMeshSettings ().GetNavMesh ();
+ if (navMesh == NULL)
+ return false;
+
+ MonoNavMeshPath monopath;
+ MarshallManagedStructIntoNative (path, &monopath);
+
+ const dtQueryFilter filter = dtQueryFilter::createFilterForIncludeFlags (passableMask);
+ int actualSize = navMesh->CalculatePolygonPath (monopath.native, sourcePosition, targetPosition, filter);
+ return actualSize>0;
+ }
+
+ // Locate the closest NavMesh edge from a point on the NavMesh.
+ CUSTOM static bool FindClosestEdge (Vector3 sourcePosition, out NavMeshHit hit, int passableMask)
+ {
+ NavMesh* navMesh = GetNavMeshSettings ().GetNavMesh ();
+ if (navMesh == NULL) {
+ InvalidateNavMeshHit (hit);
+ return false;
+ }
+ const dtQueryFilter filter = dtQueryFilter::createFilterForIncludeFlags (passableMask);
+ return navMesh->DistanceToEdge (hit, sourcePosition, filter);
+ }
+
+ // Sample the NavMesh closest to the point specified.
+ CUSTOM static bool SamplePosition (Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int allowedMask)
+ {
+ NavMesh* navMesh = GetNavMeshSettings ().GetNavMesh ();
+ if (navMesh == NULL) {
+ InvalidateNavMeshHit (hit);
+ return false;
+ }
+ const dtQueryFilter filter = dtQueryFilter::createFilterForIncludeFlags (allowedMask);
+ return navMesh->SamplePosition (hit, sourcePosition, filter, maxDistance);
+ }
+
+ // Sets the cost for traversing over geometry of the layer type on all agents.
+ CUSTOM static void SetLayerCost (int layer, float cost)
+ {
+ GetNavMeshLayers ().SetLayerCost (layer, cost);
+ }
+
+ // Gets the cost for traversing over geometry of the layer type on all agents.
+ CUSTOM static float GetLayerCost (int layer)
+ {
+ return GetNavMeshLayers ().GetLayerCost (layer);
+ }
+
+ // Returns the layer index for a named layer.
+ CUSTOM static int GetNavMeshLayerFromName (string layerName)
+ {
+ return GetNavMeshLayers ().GetNavMeshLayerFromName (layerName.AsUTF8());
+ }
+
+ CONDITIONAL !UNITY_FLASH && !UNITY_WINRT
+ CSRAW public static NavMeshTriangulation CalculateTriangulation ()
+ {
+ NavMeshTriangulation tri = new NavMeshTriangulation ();
+ TriangulateInternal (ref tri.vertices, ref tri.indices, ref tri.layers);
+ return tri;
+ }
+
+ CONDITIONAL !UNITY_FLASH && !UNITY_WINRT
+ CUSTOM internal private static void TriangulateInternal (ref Vector3[] vertices, ref int[] indices, ref int[] layers)
+ {
+ if (NavMesh* navMesh = GetNavMeshSettings ().GetNavMesh ()) {
+ NavMesh::Triangulation triangulation;
+ navMesh->Triangulate (triangulation);
+
+ vertices = CreateScriptingArray (triangulation.vertices.begin (), triangulation.vertices.size (), MONO_COMMON.vector3 );
+ indices = CreateScriptingArray (triangulation.indices.begin (), triangulation.indices.size (), MONO_COMMON.int_32 );
+ layers = CreateScriptingArray (triangulation.layers.begin (), triangulation.layers.size (), MONO_COMMON.int_32 );
+ } else {
+ vertices = CreateEmptyStructArray (MONO_COMMON.vector3);
+ indices = CreateEmptyStructArray (MONO_COMMON.int_32);
+ layers = CreateEmptyStructArray (MONO_COMMON.int_32);
+ }
+ }
+
+ //*undocumented* DEPRECATED
+ CONDITIONAL !UNITY_FLASH && !UNITY_WINRT
+ OBSOLETE warning use NavMesh.CalculateTriangulation() instead.
+ CUSTOM static void Triangulate (out Vector3[] vertices, out int[] indices)
+ {
+ if (NavMesh* navMesh = GetNavMeshSettings ().GetNavMesh ()) {
+ NavMesh::Triangulation triangulation;
+ navMesh->Triangulate (triangulation);
+ if (vertices) {
+ *vertices = CreateScriptingArray (triangulation.vertices.begin(), triangulation.vertices.size (), MONO_COMMON.vector3 );
+ }
+ if (indices) {
+ *indices = CreateScriptingArray (triangulation.indices.begin(), triangulation.indices.size (), MONO_COMMON.int_32 );
+ }
+ }
+ }
+ //*undocumented*
+ CUSTOM static void AddOffMeshLinks () { }
+ //*undocumented*
+ CUSTOM static void RestoreNavMesh () { }
+
+END
+
+// Link allowing movement outside the planar navigation mesh.
+CLASS OffMeshLink : Component
+
+ // Is link active.
+ AUTO_PROP bool activated GetActivated SetActivated
+
+ // Is link occupied. (RO)
+ AUTO_PROP bool occupied GetOccupied
+
+ // Modify pathfinding cost for the link.
+ AUTO_PROP float costOverride GetCostOverride SetCostOverride
+
+ AUTO_PROP bool biDirectional GetBiDirectional SetBiDirectional
+
+ CUSTOM void UpdatePositions () { return self->UpdatePositions (); }
+
+ AUTO_PROP int navMeshLayer GetNavMeshLayer SetNavMeshLayer
+
+ AUTO_PROP bool autoUpdatePositions GetAutoUpdatePositions SetAutoUpdatePositions
+
+ AUTO_PTR_PROP Transform startTransform GetStartTransform SetStartTransform
+
+ AUTO_PTR_PROP Transform endTransform GetEndTransform SetEndTransform
+
+END
+
+
+CSRAW }
+
diff --git a/Runtime/NavMesh/ScriptBindings/NavMeshObstacleBindings.txt b/Runtime/NavMesh/ScriptBindings/NavMeshObstacleBindings.txt
new file mode 100644
index 0000000..4c71baf
--- /dev/null
+++ b/Runtime/NavMesh/ScriptBindings/NavMeshObstacleBindings.txt
@@ -0,0 +1,40 @@
+C++RAW
+
+#include "UnityPrefix.h"
+#include "Configuration/UnityConfigure.h"
+#include "Runtime/Mono/MonoBehaviour.h"
+#include "Runtime/NavMesh/NavMeshObstacle.h"
+#include "Runtime/Scripting/ScriptingUtility.h"
+#include "Runtime/Scripting/ScriptingExportUtility.h"
+
+CSRAW
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace UnityEngine
+{
+
+// Navigation mesh obstacle.
+CLASS NavMeshObstacle : Behaviour
+
+ // Obstacle height.
+ AUTO_PROP float height GetHeight SetHeight
+
+ // Obstacle radius.
+ AUTO_PROP float radius GetRadius SetRadius
+
+ // Obstacle velocity.
+ AUTO_PROP Vector3 velocity GetVelocity SetVelocity
+
+ CONDITIONAL ENABLE_NAVMESH_CARVING
+ AUTO_PROP bool carving GetCarving SetCarving
+
+ CONDITIONAL ENABLE_NAVMESH_CARVING
+ AUTO_PROP float carvingMoveThreshold GetMoveThreshold SetMoveThreshold
+
+END
+
+CSRAW }
+
diff --git a/Runtime/NavMesh/ScriptBindings/NavMeshPathBindings.txt b/Runtime/NavMesh/ScriptBindings/NavMeshPathBindings.txt
new file mode 100644
index 0000000..9f67a39
--- /dev/null
+++ b/Runtime/NavMesh/ScriptBindings/NavMeshPathBindings.txt
@@ -0,0 +1,133 @@
+C++RAW
+
+#include "UnityPrefix.h"
+#include "Configuration/UnityConfigure.h"
+#include "Runtime/Mono/MonoBehaviour.h"
+#include "Runtime/NavMesh/NavMesh.h"
+#include "Runtime/NavMesh/NavMeshPath.h"
+#include "Runtime/NavMesh/NavMeshSettings.h"
+#include "Runtime/Scripting/ScriptingUtility.h"
+#include "Runtime/Scripting/ScriptingExportUtility.h"
+#include "Runtime/Mono/MonoManager.h"
+
+CSRAW
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace UnityEngine
+{
+
+// Keep this enum in sync with the one defined in "NavMeshPath.h"
+// Status of path.
+ENUM NavMeshPathStatus
+ // The path terminates at the destination.
+ PathComplete = 0,
+
+ // The path cannot reach the destination.
+ PathPartial = 1,
+
+ // The path is invalid.
+ PathInvalid = 2
+END
+
+CSRAW
+[StructLayout (LayoutKind.Sequential)]
+// Path navigation.
+CLASS NavMeshPath
+ CSRAW internal IntPtr m_Ptr;
+ CSRAW internal Vector3[] m_corners;
+
+ C++RAW
+
+#if !UNITY_FLASH && !UNITY_WEBGL && !UNITY_WINRT
+ #define GET ExtractMonoObjectData<NavMeshPath*>(self)
+#else
+ inline NavMeshPath* GetNativeNavMeshPath (ScriptingObjectPtr self)
+ {
+ MonoNavMeshPath managedpath;
+ MarshallManagedStructIntoNative (self, &managedpath);
+ return managedpath.native;
+ }
+ #define GET GetNativeNavMeshPath (self)
+#endif
+
+
+ // NavMeshPath constructor.
+ CUSTOM NavMeshPath ()
+ {
+ MonoNavMeshPath managedPath;
+ managedPath.native = new NavMeshPath ();
+ MarshallNativeStructIntoManaged (managedPath,self);
+ }
+
+ THREAD_SAFE
+ CUSTOM private void DestroyNavMeshPath ()
+ {
+ if (GET)
+ {
+ delete GET;
+ }
+ }
+
+ CSRAW ~NavMeshPath ()
+ {
+ DestroyNavMeshPath ();
+ m_Ptr = IntPtr.Zero;
+ }
+
+ CUSTOM private Vector3[] CalculateCornersInternal ()
+ {
+ NavMesh* navMesh = GetNavMeshSettings ().GetNavMesh ();
+ if (navMesh == NULL)
+ return CreateEmptyStructArray (GetMonoManager ().GetCommonClasses ().vector3);
+
+ const int polygonCount = GET->GetPolygonCount ();
+ if (polygonCount == 0)
+ return CreateEmptyStructArray (GetMonoManager ().GetCommonClasses ().vector3);
+
+ Vector3f* corners;
+ ALLOC_TEMP (corners, Vector3f, 2+polygonCount);
+
+ NavMeshPath* path = GET;
+ int cornerCount = navMesh->CalculatePathCorners (corners, 2+polygonCount, *path);
+ if (cornerCount == 0)
+ return CreateEmptyStructArray (GetMonoManager ().GetCommonClasses ().vector3);
+
+ return CreateScriptingArray<Vector3f>(corners, cornerCount, GetMonoManager ().GetCommonClasses ().vector3);
+ }
+
+ CUSTOM private void ClearCornersInternal ()
+ {
+ GET->SetPolygonCount (0);
+ }
+
+ // Erase all corner points from path.
+ CSRAW public void ClearCorners ()
+ {
+ ClearCornersInternal ();
+ m_corners = null;
+ }
+
+ CSRAW private void CalculateCorners ()
+ {
+ if (m_corners == null)
+ m_corners = CalculateCornersInternal ();
+ }
+
+ // Corner points of path. (RO)
+ CSRAW public Vector3[] corners { get { CalculateCorners (); return m_corners;} }
+
+ // Status of the path. (RO)
+ CUSTOM_PROP NavMeshPathStatus status
+ {
+ return GET->GetStatus ();
+ }
+
+ C++RAW
+ #undef GET
+END
+
+CSRAW }
+