public TransportPathfindResult FindShortestPath(TransportPathfindOptions options) { var optionsInterop = options.ToInterop(); var pathfindResultInterop = NativeTransportApi_FindShortestPath(NativePluginRunner.API, ref optionsInterop); if (pathfindResultInterop.IsPathFound) { // alloc and pin buffers var pathDirectedEdgeIdsBuffer = new TransportDirectedEdgeIdInterop[pathfindResultInterop.PathDirectedEdgesSize]; var pathDirectedEdgeIdsBufferGCHandle = GCHandle.Alloc(pathDirectedEdgeIdsBuffer, GCHandleType.Pinned); pathfindResultInterop.PathDirectedEdges = pathDirectedEdgeIdsBufferGCHandle.AddrOfPinnedObject(); var pathPointsBuffer = new DoubleVector3[pathfindResultInterop.PathPointsSize]; var pathPointsBufferGCHandle = GCHandle.Alloc(pathPointsBuffer, GCHandleType.Pinned); pathfindResultInterop.PathPoints = pathPointsBufferGCHandle.AddrOfPinnedObject(); var pathPointParamsBuffer = new double[pathfindResultInterop.PathPointsSize]; var pathPointParamsBufferGCHandle = GCHandle.Alloc(pathPointParamsBuffer, GCHandleType.Pinned); pathfindResultInterop.PathPointParams = pathPointParamsBufferGCHandle.AddrOfPinnedObject(); var result = PopulateAndReleaseTransportPathfindResult(pathDirectedEdgeIdsBuffer, pathPointsBuffer, pathPointParamsBuffer, ref pathfindResultInterop); pathDirectedEdgeIdsBufferGCHandle.Free(); pathPointsBufferGCHandle.Free(); pathPointParamsBufferGCHandle.Free(); return(result); } else { var failedResult = new TransportPathfindResult(); return(failedResult); } }