Awake() public method

This will be called on the same time as Awake on the gameObject which the AstarPath script is attached to. (remember, not in the editor) Use this for any initialization code which can't be placed in Scan
public Awake ( ) : void
return void
Beispiel #1
0
 public void AddGraph(NavGraph graph)
 {
     AstarPath.active.BlockUntilPathQueueBlocked();
     for (int i = 0; i < this.graphs.Length; i++)
     {
         if (this.graphs[i] == null)
         {
             this.graphs[i] = graph;
             graph.active   = AstarData.active;
             graph.Awake();
             graph.graphIndex = (uint)i;
             this.UpdateShortcuts();
             return;
         }
     }
     if (this.graphs != null && (long)this.graphs.Length >= 255L)
     {
         throw new Exception("Graph Count Limit Reached. You cannot have more than " + 255u + " graphs. Some compiler directives can change this limit, e.g ASTAR_MORE_AREAS, look under the 'Optimizations' tab in the A* Inspector");
     }
     this.graphs = new List <NavGraph>(this.graphs)
     {
         graph
     }.ToArray();
     this.UpdateShortcuts();
     graph.active = AstarData.active;
     graph.Awake();
     graph.graphIndex = (uint)(this.graphs.Length - 1);
 }
Beispiel #2
0
		/** Adds the specified graph to the #graphs array */
		public void AddGraph (NavGraph graph) {
			// Make sure to not interfere with pathfinding
			AstarPath.active.BlockUntilPathQueueBlocked();

			// Try to fill in an empty position
			for (int i = 0; i < graphs.Length; i++) {
				if (graphs[i] == null) {
					graphs[i] = graph;
					graph.active = active;
					graph.Awake();
					graph.graphIndex = (uint)i;
					UpdateShortcuts();
					return;
				}
			}

			if (graphs != null && graphs.Length >= GraphNode.MaxGraphIndex) {
				throw new System.Exception("Graph Count Limit Reached. You cannot have more than " + GraphNode.MaxGraphIndex +
					" graphs. Some compiler directives can change this limit, e.g ASTAR_MORE_AREAS, look under the " +
					"'Optimizations' tab in the A* Inspector");
			}

			//Add a new entry to the list
			var ls = new List<NavGraph>(graphs);
			ls.Add(graph);
			graphs = ls.ToArray();

			UpdateShortcuts();

			graph.active = active;
			graph.Awake();
			graph.graphIndex = (uint)(graphs.Length-1);
		}
Beispiel #3
0
        public void AddGraph(NavGraph graph)
        {
            AstarPath.active.BlockUntilPathQueueBlocked();
            bool flag = false;

            for (int i = 0; i < this.graphs.Length; i++)
            {
                if (this.graphs[i] == null)
                {
                    this.graphs[i]   = graph;
                    graph.graphIndex = (uint)i;
                    flag             = true;
                }
            }
            if (!flag)
            {
                if (this.graphs != null && (long)this.graphs.Length >= 255L)
                {
                    throw new Exception("Graph Count Limit Reached. You cannot have more than " + 255u + " graphs.");
                }
                this.graphs = new List <NavGraph>(this.graphs ?? new NavGraph[0])
                {
                    graph
                }.ToArray();
                graph.graphIndex = (uint)(this.graphs.Length - 1);
            }
            this.UpdateShortcuts();
            graph.active = AstarData.active;
            graph.Awake();
        }
Beispiel #4
0
        /** Adds the specified graph to the #graphs array */
        public void AddGraph(NavGraph graph)
        {
            // Make sure to not interfere with pathfinding
            AstarPath.active.BlockUntilPathQueueBlocked();

            // Try to fill in an empty position
            bool foundEmpty = false;

            for (int i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] == null)
                {
                    graphs[i]        = graph;
                    graph.graphIndex = (uint)i;
                    foundEmpty       = true;
                }
            }

            if (!foundEmpty)
            {
                if (graphs != null && graphs.Length >= GraphNode.MaxGraphIndex)
                {
                    throw new System.Exception("Graph Count Limit Reached. You cannot have more than " + GraphNode.MaxGraphIndex + " graphs.");
                }

                // Add a new entry to the list
                var ls = new List <NavGraph>(graphs ?? new NavGraph[0]);
                ls.Add(graph);
                graphs           = ls.ToArray();
                graph.graphIndex = (uint)(graphs.Length - 1);
            }

            UpdateShortcuts();
            graph.active = active;
            graph.Awake();
        }
Beispiel #5
0
		/** Adds the specified graph to the #graphs array */
		public void AddGraph (NavGraph graph) {
			
			// Make sure to not interfere with pathfinding
			AstarPath.active.BlockUntilPathQueueBlocked();
			
			//Try to fill in an empty position
			for (int i=0;i<graphs.Length;i++) {
				if (graphs[i] == null) {
					graphs[i] = graph;
					return;
				}
			}
			
			if (graphs != null && graphs.Length >= GraphNode.MaxGraphCount-1) {
				throw new System.Exception("Graph Count Limit Reached. You cannot have more than " + GraphNode.MaxGraphCount +
					" graphs. Some compiler directives can change this limit, e.g ASTAR_MORE_AREAS, look under the " +
					"'Optimizations' tab in the A* Inspector");
			}
			
			//Add a new entry to the list
			List<NavGraph> ls = new List<NavGraph> (graphs);
			ls.Add (graph);
			graphs = ls.ToArray ();
			
			UpdateShortcuts ();
			
			graph.active = active;
			graph.Awake ();
			graph.graphIndex = (uint)(graphs.Length-1);
		}