public void Start() { // This example assumes that there is a valid AStar grid component in the scene. // The included TileManager script can be used in this case. AStarAbstractGrid grid = AStarGridManager.DefaultGrid; // Issue a pathfinding request grid.findPath(new Index(0, 0), new Index(1, 1), onPathFound); }
// Methods public override void OnEnable() { grid = target as AStarAbstractGrid; // Construct the UI elements createUI(); base.OnEnable(); }
public static PathView findViewForGrid(AStarAbstractGrid grid) { // Find all components foreach (PathView view in Component.FindObjectsOfType <PathView>()) { // Check for observed grid if (view.visualizeGrid == grid) { // Get the component return(view); } } // Not found return(null); }
public void Start() { // This example assumes that there is a valid AStar grid component in the scene. // The included TileManager script can be used in this case. AStarAbstractGrid grid = AStarGridManager.DefaultGrid; // Create our mono delegate targeting the 'onPathFound' method and specifying 'this' mono behaviour as the receiver. // Once created, the delegate can be stored and reused in multiple pathfinding requests. MonoDelegate callback = new MonoDelegate(this, "onPathFound"); // We are also able to add additional listeners to the mono delegate which will also be called. callback.addListener(this, "onPathFoundAdditional"); // Issue a pathfinding request using our mono delegate as the callback grid.findPath(new Index(0, 0), new Index(1, 1), callback); }
public static void setRenderPath(AStarAbstractGrid grid, Path path) { // Make sure the path is valid if (path == null) { return; } // Find the component PathView view = findViewForGrid(grid); // Check for error if (view == null) { return; } // Udpate the render path view.setRenderPath(path); }