Pathfinding.AstarData.GetGraph C# (CSharp) Method

GetGraph() public static method

public static GetGraph ( GraphNode node ) : NavGraph
node GraphNode
return NavGraph
		public static NavGraph GetGraph (GraphNode node) {
			
			if (node == null) return null;
			
			AstarPath script = AstarPath.active;
			
			if (script == null) return null;
			
			AstarData data = script.astarData;
			
			if (data == null) return null;
			
			if (data.graphs == null) return null;
			
			uint graphIndex = node.GraphIndex;
			
			if (graphIndex >= data.graphs.Length) {
				return null;
			}
			
			return data.graphs[(int)graphIndex];
		}
		

Usage Example

Ejemplo n.º 1
0
        public Vector3 GetClampedPoint(Vector3 from, Vector3 to, GraphNode hint)
        {
            Vector3    point = to;
            RaycastHit hit;

            if (useRaycasting && Physics.Linecast(from, to, out hit, mask))
            {
                point = hit.point;
            }

            if (useGraphRaycasting && hint != null)
            {
                var rayGraph = AstarData.GetGraph(hint) as IRaycastableGraph;

                if (rayGraph != null)
                {
                    GraphHitInfo graphHit;
                    if (rayGraph.Linecast(from, point, hint, out graphHit))
                    {
                        point = graphHit.point;
                    }
                }
            }

            return(point);
        }
All Usage Examples Of Pathfinding.AstarData::GetGraph