docs.unity.cn
    Show / Hide Table of Contents

    Class AutoRouter

    AutoRouter utility class is used to find a route around obstacles from source to target

    Inheritance
    Object
    AutoRouter
    Namespace: Mechatronics.SystemGraph
    Syntax
    public class AutoRouter

    Methods

    ComputeEdgeSpacing(SystemEdgeControl, AutoRouter.PathDescriptor, List<EdgeDescriptor>, Single, Single)

    Compute the edge spacing so that edges don't overlap

    Declaration
    public static void ComputeEdgeSpacing(SystemEdgeControl caller, AutoRouter.PathDescriptor pathDesc, List<EdgeDescriptor> edges, float scale, float edgeSpacing = 6F)
    Parameters
    Type Name Description
    SystemEdgeControl caller

    Caller visual object to use for coordinate transformation

    AutoRouter.PathDescriptor pathDesc

    Path descriptor

    List<EdgeDescriptor> edges

    Edges to check for overlap

    Single scale

    Current scale of the graph

    Single edgeSpacing

    Tolerance used for spacing

    EdgeFineTuning(AutoRouter.PathDescriptor)

    Fine tune the edge path by creating 45 degree turns

    Declaration
    public static void EdgeFineTuning(AutoRouter.PathDescriptor pathDesc)
    Parameters
    Type Name Description
    AutoRouter.PathDescriptor pathDesc

    Path descriptor to tune

    GetRectIntersection(AutoRouter.Line, Rect, ref Vector2, ref Vector2)

    Get the intersection status and points between a line and a rect.

    Declaration
    public static bool GetRectIntersection(AutoRouter.Line a, Rect rc, ref Vector2 entry, ref Vector2 exit)
    Parameters
    Type Name Description
    AutoRouter.Line a

    Line that intersect the rect

    Rect rc

    Rect tested for intersection

    Vector2 entry

    Line enter the rect from that point

    Vector2 exit

    Line exist the rect from that point

    Returns
    Type Description
    Boolean

    True if line intersects the rect

    GetSideDistances(List<Rect>, Vector2, ref Single, ref Single)

    Get the left and right x coordinates that a line would intersect from a given point to a list of obstacles.

    Declaration
    public static void GetSideDistances(List<Rect> nodes, Vector2 start, ref float minLeftX, ref float minRightX)
    Parameters
    Type Name Description
    List<Rect> nodes

    Obstacles to test

    Vector2 start

    Start point for testing the ray

    Single minLeftX

    Minimum left obstacle collision

    Single minRightX

    Minimum right obstacle collision

    Path(ref AutoRouter.PathDescriptor, List<Rect>, Vector2, Vector2, Vector2, Vector2, Int32)

    Trace the path for a series of obstacles using the state descriptor provided

    Declaration
    public static void Path(ref AutoRouter.PathDescriptor pathDesc, List<Rect> nodes, Vector2 start, Vector2 stop, Vector2 fixedStart, Vector2 fixedStop, int iterationLimit = 30)
    Parameters
    Type Name Description
    AutoRouter.PathDescriptor pathDesc

    Path state descriptor

    List<Rect> nodes

    List of obstacles

    Vector2 start

    Start point

    Vector2 stop

    Stop point

    Vector2 fixedStart

    Fixed start point to hardcode in the path

    Vector2 fixedStop

    Fixed stop point to hardcode in the path

    Int32 iterationLimit

    Maximum number of iterations used while solving the path

    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Tuesday, October 18, 2022
    Terms of use