summaryrefslogtreecommitdiff
path: root/Runtime/NavMesh/ScriptBindings/NavMeshPathBindings.txt
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/NavMesh/ScriptBindings/NavMeshPathBindings.txt
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/NavMesh/ScriptBindings/NavMeshPathBindings.txt')
-rw-r--r--Runtime/NavMesh/ScriptBindings/NavMeshPathBindings.txt133
1 files changed, 133 insertions, 0 deletions
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 }
+