예제 #1
0
 private void ResetBuffer(PathBuffer buffer)
 {
     if (buffer != null)
     {
         buffer.SetDataCount(0);
     }
 }
예제 #2
0
        public PathBuffer _FindPath(Vector3 start, Vector3 end, Vector3 extends, NavmeshQueryFilter filter = null)
        {
            var query = this.Query;

            if (query == null)
            {
                return(null);
            }
            if (filter == null)
            {
                filter = this.DefaultQueryFilter;
            }
            NavmeshPoint startPoint;
            var          status = query.GetNearestPoint(start, extends, filter, out startPoint);

            if (NavUtil.Failed(status))
            {
                return(null);
            }
            NavmeshPoint endPoint;

            status = query.GetNearestPoint(end, extends, filter, out endPoint);
            if (NavUtil.Failed(status))
            {
                return(null);
            }

            PathBuffer pathBuf = GetPathBuffer();

            if (pathBuf == null || pathBuf.Buffer == null)
            {
                return(null);
            }
            try
            {
                int dataCount;
                status = query.FindPath(ref startPoint, ref endPoint, extends, filter, pathBuf.Buffer, out dataCount);
                if (NavUtil.Failed(status))
                {
                    return(null);
                }

                pathBuf.SetDataCount(dataCount);

                return(pathBuf);
            } catch
            {
                StorePathBuffer(pathBuf);
            }
            return(null);
        }