[ASSET] A* Pathfinding

This commit is contained in:
IDMhan 2024-02-21 03:34:40 +09:00
parent 16f3c94def
commit 1d456666f0
590 changed files with 6619 additions and 5309 deletions

View File

@ -5,3 +5,10 @@ AssemblyDefinitionImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/AstarPathfindingProject.asmdef
uploadId: 626197

View File

@ -12,7 +12,7 @@ namespace Pathfinding {
/// [Open online documentation to see images]
/// </summary>
[UniqueComponent(tag = "ai.destination")]
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_a_i_destination_setter.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_a_i_destination_setter.php")]
public class AIDestinationSetter : VersionedMonoBehaviour {
/// <summary>The object that the AI should move to</summary>
public Transform target;

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Behaviors/AIDestinationSetter.cs
uploadId: 626197

View File

@ -13,7 +13,7 @@ namespace Pathfinding {
/// See: <see cref="Pathfinding.AILerp"/>
/// </summary>
[UniqueComponent(tag = "ai.destination")]
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_patrol.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_patrol.php")]
public class Patrol : VersionedMonoBehaviour {
/// <summary>Target points to move to in order</summary>
public Transform[] targets;
@ -21,11 +21,18 @@ namespace Pathfinding {
/// <summary>Time in seconds to wait at each target</summary>
public float delay = 0;
/// <summary>
/// If true, the agent's destination will be updated every frame instead of only when switching targets.
///
/// This is good if you have moving targets, but is otherwise unnecessary and slightly slower.
/// </summary>
public bool updateDestinationEveryFrame = false;
/// <summary>Current target index</summary>
int index;
int index = -1;
IAstarAI agent;
float switchTime = float.PositiveInfinity;
float switchTime = float.NegativeInfinity;
protected override void Awake () {
base.Awake();
@ -36,8 +43,6 @@ namespace Pathfinding {
void Update () {
if (targets.Length == 0) return;
bool search = false;
// Note: using reachedEndOfPath and pathPending instead of reachedDestination here because
// if the destination cannot be reached by the agent, we don't want it to get stuck, we just want it to get as close as possible and then move on.
if (agent.reachedEndOfPath && !agent.pathPending && float.IsPositiveInfinity(switchTime)) {
@ -45,15 +50,16 @@ namespace Pathfinding {
}
if (Time.time >= switchTime) {
index = index + 1;
search = true;
index++;
switchTime = float.PositiveInfinity;
index = index % targets.Length;
agent.destination = targets[index].position;
agent.SearchPath();
} else if (updateDestinationEveryFrame) {
index = index % targets.Length;
agent.destination = targets[index].position;
}
index = index % targets.Length;
agent.destination = targets[index].position;
if (search) agent.SearchPath();
}
}
}

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Behaviors/Patrol.cs
uploadId: 626197

View File

@ -1,3 +1,54 @@
## 4.2.19 (2023-11-14)
- This release contains fixes and features that have been backported from the 4.3 beta.
The beta version contains a lot more exciting new features and fixes.
You can download the 4.3 beta at https://www.arongranberg.com/astar/download.
- The documentation now has a dropdown to allow you to choose between different versions of the package, and a notification if you are viewing a previous version.
\shadowimage{changelog/documentation_version_dropdown.png}
- Added a new tutorial: \ref traversal_provider.
- You can now set a custom traversal provider on the Seeker component, and it will be applied to all path requests. See \reflink{Seeker.traversalProvider}.
- Changed \link Pathfinding.Seeker.IsDone Seeker.IsDone\endlink to return true from within the OnPathComplete callback.
Previously it would always return false, which was confusing since the callback explicitly indicates that the path has been calculated.
- Made the grid graph's collision visualization in the inspector green instead of blue.
This is done to make the connection to colliders more clear. The color is also easier to see against the grey background.
- The \reflink{RaycastModifier} now defaults to graph raycasting in the pro version of the package.
- The transform tool for the GameObject with the AstarPath component is now hidden to reduce clutter, as each graph has its own transform tool instead.
- \reflink{AutoRepathPolicy} will now automatically randomly spread out path recalculations a bit to avoid many agents recalculating their paths at the same time.
- Added \reflink{GraphMask.FromGraphIndex}.
- Added an option for a custom edge filter in \reflink{GraphUtilities.GetContours}.
- Added \reflink{GridGraph.GetNeighbourDirections}.
- Added \reflink{NavGraph.isScanned}.
- Added \reflink{NavGraph.IsInsideBounds}.
- Added \reflink{GraphNode.ContainsPoint} and \reflink{GraphNode.ContainsPointInGraphSpace}.
- Added \reflink{GridGraph.AlignToTilemap}.
- Added \reflink{IAstarAI.endOfPath}.
- Added \reflink{GridNodeBase.HasConnectionsToAllAxisAlignedNeighbours}.
- Added \reflink{GraphUpdateScene.GetGraphUpdate}.
- Added \reflink{ABPath.cost} for accessing the total cost of a calculated path.
- Added a way to align a grid graph to a tilemap. Previously this has been quite tricky, especially for isometric and hexagonal tilemap layouts.
\shadowimage{gridgraph/align_to_tilemap.png}
- Added ASTAR_LARGER_GRIDS which can be set under the Optimizations tab to enable grid graphs larger than 1024x1024.
- Changed how \reflink{GridGraph.aspectRatio} works for isometric and hexagonal grid graphs. Now it works more intuitively to just make the nodes N times wider.
Before it only behaved properly for rectangular grid graphs.
- Deprecated NNConstraint.Default. Use the equivalent \reflink{NNConstraint.Walkable} property instead, as this name is more descriptive.
- Deprecated \reflink{AIPath.OnTargetReached}, \reflink{RichAI.OnTargetReached}, \reflink{AILerp.OnTargetReached}.
You can use \reflink{IAstarAI.reachedDestination} or \reflink{IAstarAI.reachedEndOfPath} instead.
The OnTargetReached method will continue to work as before, but using it is discouraged.
- Deprecated the AdvancedSmooth modifier. It never worked particularly well, and given that no one has asked a single support question about it the last 5 years or so, I don't think a lot of people use it.
- Fixed \link Pathfinding.IAstarAI.SetPath ai.SetPath\endlink did not accept paths if you called it from the OnPathComplete callback for the path.
- Fixed the first tag color in the inspector would sometimes be initialized to completely transparent.
- Fixed \reflink{NavmeshCut}s with custom meshes could calculate an incorrect bounding box, which could lead to it not updating some tiles, even if it was touching them.
- Fixed \reflink{GraphUpdateScene.GetBounds} sometimes incorrectly returning an empty bounding box if the \a convex option was enabled.
- Fixed some cases where a recast graph would miss some connections between nodes in different tiles. Especially if the shared edge was long.
- Fixed Navmesh Cutting Update Interval would not be serialized, and therefore always reset to 0 when the game started.
- Fixed the grid graph's collision preview showing the side view when using 2D physics even though that's irrelevant for 2D.
- Fixed an exception could in rare circumstances be thrown when using \reflink{ABPath.calculatePartial}.
- Fixed editor-only data would sometimes not be loaded from graphs, leading to some settings in the graph inspectors to be lost (e.g. if the grid graph's collision preview was open or closed).
- Fixed \reflink{TriangleMeshNode.ContainsConnection} could throw an exception if the node had no connections at all.
- Fixed calling \reflink{GraphUtilities.GetContours} with a grid graph that had one-way connections could cause an infinite loop.
Now an exception will be thrown if any one-way connections are found. This is reasonable because the contours of a grid graph are not really well-defined if any one-way connections exist.
- Removed previously deprecated methods on the Path class: GetState, Log, LogError and ReleaseSilent. They have all been deprecated for over 5 years.
- Removed previously deprecated methods on the AstarData class: GetGraphType(string), CreateGraph(string), AddGraph(string, and GetRaycastableGraphs. They have all been deprecated for over 5 years.
## 4.2.18 (2022-11-08)
- This release contains fixes and features that have been backported from the 4.3 beta.
You can download the 4.3 beta at https://www.arongranberg.com/astar/download.
@ -595,7 +646,7 @@
- Fixed some cases where the funnel modifier would produce incorrect results.
- Fixed typo in a private method in the AstarPath class. Renamed the UpdateGraphsInteral method to UpdateGraphsInternal.
- Fixed AIPath.remainingDistance and AIPath.targetReached could be incorrect for 1 frame when a new path had just been calculated (introduced in a previous beta release).
## 4.0.11 (2017-09-09)
- Fixed paths would ignore the ITraversalProvider (used for the turn based utilities) on the first node of the path, resulting in successful paths where they should have failed.
- Fixed BlockManager.BlockMode.AllExceptSelector could often produce incorrect results. Thanks Cquels for spotting the bug.

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/CHANGELOG.md
uploadId: 626197

View File

@ -322,11 +322,13 @@ namespace Pathfinding {
}
}
/// <summary>
/// Velocity that this agent wants to move with.
/// Includes gravity and local avoidance if applicable.
/// </summary>
public Vector3 desiredVelocity { get { return lastDeltaTime > 0.00001f ? movementPlane.ToWorld(lastDeltaPosition / lastDeltaTime, verticalVelocity) : Vector3.zero; } }
/// <summary>\copydoc Pathfinding::IAstarAI::desiredVelocity</summary>
public Vector3 desiredVelocity {
get { return lastDeltaTime > 0.00001f ? movementPlane.ToWorld(lastDeltaPosition / lastDeltaTime, verticalVelocity) : Vector3.zero; }
}
/// <summary>\copydoc Pathfinding::IAstarAI::endOfPath</summary>
public abstract Vector3 endOfPath { get; }
/// <summary>\copydoc Pathfinding::IAstarAI::isStopped</summary>
public bool isStopped { get; set; }
@ -524,7 +526,7 @@ namespace Pathfinding {
seeker.CancelCurrentPathRequest();
seeker.StartPath(path);
autoRepath.DidRecalculatePath(destination);
} else if (path.PipelineState == PathState.Returned) {
} else if (path.PipelineState >= PathState.Returning) {
// Path has already been calculated
// We might be calculating another path at the same time, and we don't want that path to override this one. So cancel it.

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AI/AIBase.cs
uploadId: 626197

View File

@ -37,7 +37,8 @@ namespace Pathfinding {
/// </summary>
[RequireComponent(typeof(Seeker))]
[AddComponentMenu("Pathfinding/AI/AILerp (2D,3D)")]
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_a_i_lerp.php")]
[UniqueComponent(tag = "ai")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_a_i_lerp.php")]
public class AILerp : VersionedMonoBehaviour, IAstarAI {
/// <summary>
/// Determines how often it will search for new paths.
@ -211,6 +212,13 @@ namespace Pathfinding {
}
}
/// <summary>\copydoc Pathfinding::IAstarAI::endOfPath</summary>
public Vector3 endOfPath {
get {
return interpolator.valid ? interpolator.endPoint : destination;
}
}
#region IAstarAI implementation
/// <summary>\copydoc Pathfinding::IAstarAI::Move</summary>
@ -473,6 +481,8 @@ namespace Pathfinding {
/// add it here.
/// You can also create a new script which inherits from this one
/// and override the function in that script.
///
/// Deprecated: Avoid overriding this method. Instead poll the <see cref="reachedDestination"/> or <see cref="reachedEndOfPath"/> properties.
/// </summary>
public virtual void OnTargetReached () {
}
@ -575,7 +585,7 @@ namespace Pathfinding {
seeker.CancelCurrentPathRequest();
seeker.StartPath(path);
autoRepath.DidRecalculatePath(destination);
} else if (path.PipelineState == PathState.Returned) {
} else if (path.PipelineState >= PathState.Returning) {
// Path has already been calculated
// We might be calculating another path at the same time, and we don't want that path to override this one. So cancel it.

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AI/AILerp.cs
uploadId: 626197

View File

@ -62,6 +62,7 @@ namespace Pathfinding {
/// It may take one or sometimes multiple frames for the path to be calculated, but finally the <see cref="OnPathComplete"/> method will be called and the current path that the AI is following will be replaced.
/// </summary>
[AddComponentMenu("Pathfinding/AI/AIPath (2D,3D)")]
[UniqueComponent(tag = "ai")]
public partial class AIPath : AIBase, IAstarAI {
/// <summary>
/// How quickly the agent accelerates.
@ -223,6 +224,13 @@ namespace Pathfinding {
}
}
/// <summary>\copydoc Pathfinding::IAstarAI::endOfPath</summary>
public override Vector3 endOfPath {
get {
return interpolator.valid ? interpolator.endPoint : destination;
}
}
/// <summary>\copydoc Pathfinding::IAstarAI::radius</summary>
float IAstarAI.radius { get { return radius; } set { radius = value; } }
@ -270,6 +278,8 @@ namespace Pathfinding {
///
/// This method will be called again if a new path is calculated as the destination may have changed.
/// So when the agent is close to the destination this method will typically be called every <see cref="repathRate"/> seconds.
///
/// Deprecated: Avoid overriding this method. Instead poll the <see cref="reachedDestination"/> or <see cref="reachedEndOfPath"/> properties.
/// </summary>
public virtual void OnTargetReached () {
}
@ -451,7 +461,7 @@ namespace Pathfinding {
}
}
static NNConstraint cachedNNConstraint = NNConstraint.Default;
static NNConstraint cachedNNConstraint = NNConstraint.Walkable;
protected override Vector3 ClampToNavmesh (Vector3 position, out bool positionChanged) {
if (constrainInsideGraph) {
cachedNNConstraint.tags = seeker.traversableTags;

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AI/AIPath.cs
uploadId: 626197

View File

@ -139,6 +139,18 @@ namespace Pathfinding {
/// </summary>
bool reachedEndOfPath { get; }
/// <summary>
/// End point of path the agent is currently following.
/// If the agent has no path (or it might not be calculated yet), this will return the <see cref="destination"/> instead.
/// If the agent has no destination it either it will return (+inf,+inf,+inf).
///
/// The end of the path is usually identical or very close to the <see cref="destination"/>, but it may differ
/// if the path for example was blocked by a wall so that the agent couldn't get any closer.
///
/// This is only updated when the path is recalculated.
/// </summary>
Vector3 endOfPath { get; }
/// <summary>
/// Position in the world that this agent should move to.
///

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AI/IAstarAI.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AI/NavmeshController.cs
uploadId: 626197

View File

@ -7,6 +7,7 @@ namespace Pathfinding {
using Pathfinding.Util;
[AddComponentMenu("Pathfinding/AI/RichAI (3D, for navmesh)")]
[UniqueComponent(tag = "ai")]
/// <summary>
/// Advanced AI for navmesh based graphs.
///
@ -216,6 +217,13 @@ namespace Pathfinding {
}
}
/// <summary>\copydoc Pathfinding::IAstarAI::endOfPath</summary>
public override Vector3 endOfPath {
get {
return hasPath ? richPath.Endpoint : destination;
}
}
/// <summary>
/// \copydoc Pathfinding::IAstarAI::Teleport
///
@ -332,7 +340,11 @@ namespace Pathfinding {
richPath.GetRemainingPath(buffer, simulatedPosition, out stale);
}
/// <summary>Called when the end of the path is reached</summary>
/// <summary>
/// Called when the end of the path is reached.
///
/// Deprecated: Avoid overriding this method. Instead poll the <see cref="reachedDestination"/> or <see cref="reachedEndOfPath"/> properties.
/// </summary>
protected virtual void OnTargetReached () {
}

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AI/RichAI.cs
uploadId: 626197

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AI/RichPath.cs
uploadId: 626197

View File

@ -15,7 +15,7 @@ namespace Pathfinding {
/// See: modifiers (view in online documentation for working links)
/// </summary>
[AddComponentMenu("Pathfinding/Seeker")]
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_seeker.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_seeker.php")]
public class Seeker : VersionedMonoBehaviour {
/// <summary>
/// Enables drawing of the last calculated path using Gizmos.
@ -81,7 +81,7 @@ namespace Pathfinding {
/// GraphMask mask1 = GraphMask.FromGraphName("My Grid Graph");
/// GraphMask mask2 = GraphMask.FromGraphName("My Other Grid Graph");
///
/// NNConstraint nn = NNConstraint.Default;
/// NNConstraint nn = NNConstraint.Walkable;
///
/// nn.graphMask = mask1 | mask2;
///
@ -99,6 +99,19 @@ namespace Pathfinding {
[HideInInspector]
public GraphMask graphMask = GraphMask.everything;
/// <summary>
/// Custom traversal provider to calculate which nodes are traversable and their penalties.
///
/// This can be used to override the built-in pathfinding logic.
///
/// <code>
/// seeker.traversalProvider = new MyCustomTraversalProvider();
/// </code>
///
/// See: traversal_provider (view in online documentation for working links)
/// </summary>
public ITraversalProvider traversalProvider;
/// <summary>Used for serialization backwards compatibility</summary>
[UnityEngine.Serialization.FormerlySerializedAs("graphMask")]
int graphMaskCompatibility = -1;
@ -116,6 +129,7 @@ namespace Pathfinding {
/// <summary>Called after a path has been calculated, right before modifiers are executed.</summary>
public OnPathDelegate postProcessPath;
#if UNITY_EDITOR
/// <summary>Used for drawing gizmos</summary>
[System.NonSerialized]
List<Vector3> lastCompletedVectorPath;
@ -123,6 +137,7 @@ namespace Pathfinding {
/// <summary>Used for drawing gizmos</summary>
[System.NonSerialized]
List<GraphNode> lastCompletedNodePath;
#endif
/// <summary>The current path</summary>
[System.NonSerialized]
@ -167,11 +182,9 @@ namespace Pathfinding {
/// Path that is currently being calculated or was last calculated.
/// You should rarely have to use this. Instead get the path when the path callback is called.
///
/// See: pathCallback
/// See: <see cref="StartPath"/>
/// </summary>
public Path GetCurrentPath () {
return path;
}
public Path GetCurrentPath() => path;
/// <summary>
/// Stop calculating the current path request.
@ -205,7 +218,7 @@ namespace Pathfinding {
/// See: <see cref="ReleaseClaimedPath"/>
/// See: <see cref="startEndModifier"/>
/// </summary>
public void OnDestroy () {
void OnDestroy () {
ReleaseClaimedPath();
startEndModifier.OnDestroy(this);
}
@ -244,8 +257,7 @@ namespace Pathfinding {
/// Post Processes the path.
/// This will run any modifiers attached to this GameObject on the path.
/// This is identical to calling RunModifiers(ModifierPass.PostProcess, path)
/// See: RunModifiers
/// Since: Added in 3.2
/// See: <see cref="RunModifiers"/>
/// </summary>
public void PostProcess (Path path) {
RunModifiers(ModifierPass.PostProcess, path);
@ -272,21 +284,16 @@ namespace Pathfinding {
/// Is the current path done calculating.
/// Returns true if the current <see cref="path"/> has been returned or if the <see cref="path"/> is null.
///
/// Note: Do not confuse this with Pathfinding.Path.IsDone. They usually return the same value, but not always
/// since the path might be completely calculated, but it has not yet been processed by the Seeker.
/// Note: Do not confuse this with Pathfinding.Path.IsDone. They usually return the same value, but not always.
/// The path might be completely calculated, but has not yet been processed by the Seeker.
///
/// Since: Added in 3.0.8
/// Version: Behaviour changed in 3.2
/// Inside the OnPathComplete callback this method will return true.
///
/// Version: Before version 4.2.19 this would return false inside the OnPathComplete callback. However this behaviour was unintuitive.
/// </summary>
public bool IsDone () {
return path == null || path.PipelineState >= PathState.Returned;
}
public bool IsDone() => path == null || path.PipelineState >= PathState.Returning;
/// <summary>
/// Called when a path has completed.
/// This should have been implemented as optional parameter values, but that didn't seem to work very well with delegates (the values weren't the default ones)
/// See: OnPathComplete(Path,bool,bool)
/// </summary>
/// <summary>Called when a path has completed</summary>
void OnPathComplete (Path path) {
OnPathComplete(path, true, true);
}
@ -311,8 +318,10 @@ namespace Pathfinding {
if (sendCallbacks) {
p.Claim(this);
#if UNITY_EDITOR
lastCompletedNodePath = p.path;
lastCompletedVectorPath = p.vectorPath;
#endif
// This will send the path to the callback (if any) specified when calling StartPath
if (tmpPathCallback != null) {
@ -470,6 +479,7 @@ namespace Pathfinding {
p.enabledTags = traversableTags;
p.tagPenalties = tagPenalties;
if (traversalProvider != null) p.traversalProvider = traversalProvider;
// Cancel a previously requested path is it has not been processed yet and also make sure that it has not been recycled and used somewhere else
if (path != null && path.PipelineState <= PathState.Processing && path.CompleteState != PathCompleteState.Error && lastPathID == path.pathID) {
@ -562,6 +572,7 @@ namespace Pathfinding {
return p;
}
#if UNITY_EDITOR
/// <summary>Draws gizmos for the Seeker</summary>
public void OnDrawGizmos () {
if (lastCompletedNodePath == null || !drawGizmos) {
@ -586,6 +597,7 @@ namespace Pathfinding {
}
}
}
#endif
protected override int OnUpgradeSerializedData (int version, bool unityThread) {
if (graphMaskCompatibility != -1) {

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AI/Seeker.cs
uploadId: 626197

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Pathfinding.Examples {
/// <summary>Helper script in the example scene 'Turn Based'</summary>
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_examples_1_1_turn_based_a_i.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_examples_1_1_turn_based_a_i.php")]
public class TurnBasedAI : VersionedMonoBehaviour {
public int movementPoints = 2;
public BlockManager blockManager;

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AI/TurnBasedAI.cs
uploadId: 626197

View File

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using Pathfinding.WindowsStore;
using Pathfinding.Serialization;
using Pathfinding.Util;
#if UNITY_WINRT && !UNITY_EDITOR
//using MarkerMetro.Unity.WinLegacy.IO;
//using MarkerMetro.Unity.WinLegacy.Reflection;
@ -13,7 +14,7 @@ namespace Pathfinding {
/// <summary>
/// Stores the navigation graphs for the A* Pathfinding System.
///
/// An instance of this class is assigned to AstarPath.data, from it you can access all graphs loaded through the <see cref="graphs"/> variable.
/// An instance of this class is assigned to <see cref="AstarPath.data"/>. From it you can access all graphs loaded through the <see cref="graphs"/> variable.
/// This class also handles a lot of the high level serialization.
/// </summary>
public class AstarData {
@ -25,38 +26,23 @@ namespace Pathfinding {
}
#region Fields
/// <summary>
/// Shortcut to the first NavMeshGraph.
/// Updated at scanning time
/// </summary>
/// <summary>Shortcut to the first <see cref="NavMeshGraph"/></summary>
public NavMeshGraph navmesh { get; private set; }
#if !ASTAR_NO_GRID_GRAPH
/// <summary>
/// Shortcut to the first GridGraph.
/// Updated at scanning time
/// </summary>
/// <summary>Shortcut to the first <see cref="GridGraph"/></summary>
public GridGraph gridGraph { get; private set; }
/// <summary>
/// Shortcut to the first LayerGridGraph.
/// Updated at scanning time.
/// </summary>
/// <summary>Shortcut to the first <see cref="LayerGridGraph"/>.</summary>
public LayerGridGraph layerGridGraph { get; private set; }
#endif
#if !ASTAR_NO_POINT_GRAPH
/// <summary>
/// Shortcut to the first PointGraph.
/// Updated at scanning time
/// </summary>
/// <summary>Shortcut to the first <see cref="PointGraph"/>.</summary>
public PointGraph pointGraph { get; private set; }
#endif
/// <summary>
/// Shortcut to the first RecastGraph.
/// Updated at scanning time.
/// </summary>
/// <summary>Shortcut to the first <see cref="RecastGraph"/>.</summary>
public RecastGraph recastGraph { get; private set; }
/// <summary>
@ -84,43 +70,25 @@ namespace Pathfinding {
#endif
/// <summary>
/// All graphs this instance holds.
/// All graphs.
/// This will be filled only after deserialization has completed.
/// May contain null entries if graph have been removed.
/// </summary>
[System.NonSerialized]
public NavGraph[] graphs = new NavGraph[0];
//Serialization Settings
/// <summary>
/// Serialized data for all graphs and settings.
/// Stored as a base64 encoded string because otherwise Unity's Undo system would sometimes corrupt the byte data (because it only stores deltas).
///
/// This can be accessed as a byte array from the <see cref="data"/> property.
///
/// Since: 3.6.1
/// </summary>
[SerializeField]
string dataString;
/// <summary>
/// Data from versions from before 3.6.1.
/// Used for handling upgrades
/// Since: 3.6.1
/// </summary>
[SerializeField]
[UnityEngine.Serialization.FormerlySerializedAs("data")]
private byte[] upgradeData;
/// <summary>Serialized data for all graphs and settings</summary>
private byte[] data {
get {
// Handle upgrading from earlier versions than 3.6.1
if (upgradeData != null && upgradeData.Length > 0) {
data = upgradeData;
upgradeData = null;
}
return dataString != null? System.Convert.FromBase64String(dataString) : null;
}
set {
@ -134,13 +102,6 @@ namespace Pathfinding {
/// </summary>
public TextAsset file_cachedStartup;
/// <summary>
/// Serialized data for cached startup.
///
/// Deprecated: Deprecated since 3.6, AstarData.file_cachedStartup is now used instead
/// </summary>
public byte[] data_cachedStartup;
/// <summary>
/// Should graph-data be cached.
/// Caching the startup means saving the whole graphs - not only the settings - to a file (<see cref="file_cachedStartup)"/> which can
@ -157,9 +118,7 @@ namespace Pathfinding {
#endregion
public byte[] GetData () {
return data;
}
public byte[] GetData() => data;
public void SetData (byte[] data) {
this.data = data;
@ -290,9 +249,7 @@ namespace Pathfinding {
/// See: Pathfinding.Serialization.SerializeSettings
/// </summary>
public byte[] SerializeGraphs (SerializeSettings settings) {
uint checksum;
return SerializeGraphs(settings, out checksum);
return SerializeGraphs(settings, out var _);
}
/// <summary>
@ -400,7 +357,7 @@ namespace Pathfinding {
sr.DeserializeEditorSettingsCompatibility();
sr.DeserializeExtraInfo();
//Assign correct graph indices.
// Assign correct graph indices.
for (int i = 0; i < graphs.Length; i++) {
if (graphs[i] == null) continue;
graphs[i].GetNodes(node => node.GraphIndex = (uint)i);
@ -472,40 +429,6 @@ namespace Pathfinding {
}
#region GraphCreation
/// <summary>
/// Returns: A System.Type which matches the specified type string. If no mathing graph type was found, null is returned
///
/// Deprecated:
/// </summary>
[System.Obsolete("If really necessary. Use System.Type.GetType instead.")]
public System.Type GetGraphType (string type) {
for (int i = 0; i < graphTypes.Length; i++) {
if (graphTypes[i].Name == type) {
return graphTypes[i];
}
}
return null;
}
/// <summary>
/// Creates a new instance of a graph of type type. If no matching graph type was found, an error is logged and null is returned
/// Returns: The created graph
/// See: <see cref="CreateGraph(System.Type)"/>
///
/// Deprecated:
/// </summary>
[System.Obsolete("Use CreateGraph(System.Type) instead")]
public NavGraph CreateGraph (string type) {
Debug.Log("Creating Graph of type '"+type+"'");
for (int i = 0; i < graphTypes.Length; i++) {
if (graphTypes[i].Name == type) {
return CreateGraph(graphTypes[i]);
}
}
Debug.LogError("Graph type ("+type+") wasn't found");
return null;
}
/// <summary>
/// Creates a new graph instance of type type
@ -519,29 +442,10 @@ namespace Pathfinding {
}
/// <summary>
/// Adds a graph of type type to the <see cref="graphs"/> array
///
/// Deprecated:
/// Adds a graph of type T to the <see cref="graphs"/> array.
/// See: runtime-graphs (view in online documentation for working links)
/// </summary>
[System.Obsolete("Use AddGraph(System.Type) instead")]
public NavGraph AddGraph (string type) {
NavGraph graph = null;
for (int i = 0; i < graphTypes.Length; i++) {
if (graphTypes[i].Name == type) {
graph = CreateGraph(graphTypes[i]);
}
}
if (graph == null) {
Debug.LogError("No NavGraph of type '"+type+"' could be found");
return null;
}
AddGraph(graph);
return graph;
}
public T AddGraph<T> () where T : NavGraph => AddGraph(typeof(T)) as T;
/// <summary>
/// Adds a graph of type type to the <see cref="graphs"/> array.
@ -607,14 +511,9 @@ namespace Pathfinding {
/// The empty position will be reused if a new graph is added.
///
/// Returns: True if the graph was sucessfully removed (i.e it did exist in the <see cref="graphs"/> array). False otherwise.
///
/// Version: Changed in 3.2.5 to call SafeOnDestroy before removing
/// and nulling it in the array instead of removing the element completely in the <see cref="graphs"/> array.
/// </summary>
public bool RemoveGraph (NavGraph graph) {
// Make sure the pathfinding threads are stopped
// If we don't wait until pathfinding that is potentially running on
// this graph right now we could end up with NullReferenceExceptions
// Make sure the pathfinding threads are paused
var graphLock = AssertSafe();
((IGraphInternals)graph).OnDestroy();
@ -713,24 +612,6 @@ namespace Pathfinding {
}
}
/// <summary>
/// All graphs which implements the UpdateableGraph interface
/// <code> foreach (IRaycastableGraph graph in AstarPath.data.GetRaycastableGraphs ()) {
/// //Do something with the graph
/// } </code>
/// See: Pathfinding.IRaycastableGraph
/// Deprecated: Deprecated because it is not used by the package internally and the use cases are few. Iterate through the <see cref="graphs"/> array instead.
/// </summary>
[System.Obsolete("Obsolete because it is not used by the package internally and the use cases are few. Iterate through the graphs array instead.")]
public IEnumerable GetRaycastableGraphs () {
if (graphs == null) yield break;
for (int i = 0; i < graphs.Length; i++) {
if (graphs[i] is IRaycastableGraph) {
yield return graphs[i];
}
}
}
/// <summary>Gets the index of the NavGraph in the <see cref="graphs"/> array</summary>
public int GetGraphIndex (NavGraph graph) {
if (graph == null) throw new System.ArgumentNullException("graph");

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AstarData.cs
uploadId: 626197

View File

@ -268,36 +268,36 @@ namespace Pathfinding {
/// Returns: the shortest squared distance between S1 and S2
/// </summary>
public static float SqrDistanceSegmentSegment (Vector3 s1, Vector3 e1, Vector3 s2, Vector3 e2) {
Vector3 u = e1 - s1;
Vector3 v = e2 - s2;
Vector3 w = s1 - s2;
double a = Vector3.Dot(u, u); // always >= 0
double b = Vector3.Dot(u, v);
double c = Vector3.Dot(v, v); // always >= 0
double d = Vector3.Dot(u, w);
double e = Vector3.Dot(v, w);
double D = a*c - b*b; // always >= 0
Vector3 dir1 = e1 - s1;
Vector3 dir2 = e2 - s2;
Vector3 startOffset = s1 - s2;
double dir1sq = Vector3.Dot(dir1, dir1); // always >= 0
double b = Vector3.Dot(dir1, dir2);
double dir2sq = Vector3.Dot(dir2, dir2); // always >= 0
double d = Vector3.Dot(dir1, startOffset);
double e = Vector3.Dot(dir2, startOffset);
double D = dir1sq*dir2sq - b*b; // always >= 0
double sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
double tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
// compute the line parameters of the two closest points
// D is approximately |v|^2|u|^2*(1-cos alpha), where alpha is the angle between the lines
if (D < 0.00001) { // the lines are almost parallel
// D is approximately |dir1|^2|dir2|^2*(1-cos^2 alpha), where alpha is the angle between the lines
if (D < 0.000001 * dir1sq*dir2sq) { // the lines are almost parallel
sN = 0.0f; // force using point P0 on segment S1
sD = 1.0f; // to prevent possible division by 0.0 later
tN = e;
tD = c;
tD = dir2sq;
} else { // get the closest points on the infinite lines
sN = (b*e - c*d);
tN = (a*e - b*d);
sN = (b*e - dir2sq*d);
tN = (dir1sq*e - b*d);
if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
sN = 0.0;
tN = e;
tD = c;
tD = dir2sq;
} else if (sN > sD) { // sc > 1 => the s=1 edge is visible
sN = sD;
tN = e + b;
tD = c;
tD = dir2sq;
}
}
@ -306,22 +306,22 @@ namespace Pathfinding {
// recompute sc for this edge
if (-d < 0.0f)
sN = 0.0f;
else if (-d > a)
else if (-d > dir1sq)
sN = sD;
else {
sN = -d;
sD = a;
sD = dir1sq;
}
} else if (tN > tD) { // tc > 1 => the t=1 edge is visible
tN = tD;
// recompute sc for this edge
if ((-d + b) < 0.0f)
sN = 0;
else if ((-d + b) > a)
else if ((-d + b) > dir1sq)
sN = sD;
else {
sN = (-d + b);
sD = a;
sD = dir1sq;
}
}
@ -330,7 +330,7 @@ namespace Pathfinding {
tc = (Math.Abs(tN) < 0.00001f ? 0.0 : tN / tD);
// get the difference of the two closest points
Vector3 dP = w + ((float)sc * u) - ((float)tc * v); // = S1(sc) - S2(tc)
Vector3 dP = startOffset + ((float)sc * dir1) - ((float)tc * dir2); // = S1(sc) - S2(tc)
return dP.sqrMagnitude; // return the closest distance
}

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AstarMath.cs
uploadId: 626197

View File

@ -20,10 +20,10 @@ using Thread = System.Threading.Thread;
/// This class is a singleton class, meaning there should only exist at most one active instance of it in the scene.
/// It might be a bit hard to use directly, usually interfacing with the pathfinding system is done through the <see cref="Pathfinding.Seeker"/> class.
/// </summary>
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_astar_path.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_astar_path.php")]
public class AstarPath : VersionedMonoBehaviour {
/// <summary>The version number for the A* Pathfinding Project</summary>
public static readonly System.Version Version = new System.Version(4, 2, 18);
public static readonly System.Version Version = new System.Version(4, 2, 19);
/// <summary>Information about where the package was downloaded</summary>
public enum AstarDistribution { WebsiteDownload, AssetStore, PackageManager };
@ -568,7 +568,7 @@ public class AstarPath : VersionedMonoBehaviour {
/// Handles navmesh cuts.
/// See: <see cref="Pathfinding.NavmeshCut"/>
/// </summary>
public readonly NavmeshUpdates navmeshUpdates = new NavmeshUpdates();
public NavmeshUpdates navmeshUpdates = new NavmeshUpdates();
/// <summary>Processes work items</summary>
readonly WorkItemProcessor workItems;
@ -621,6 +621,7 @@ public class AstarPath : VersionedMonoBehaviour {
workItems = new WorkItemProcessor(this);
graphUpdates = new GraphUpdateProcessor(this);
navmeshUpdates.astar = this;
// Forward graphUpdates.OnGraphsUpdated to AstarPath.OnGraphsUpdated
graphUpdates.OnGraphsUpdated += () => {
@ -753,8 +754,6 @@ public class AstarPath : VersionedMonoBehaviour {
colorSettings.PushToStatic(this);
AstarProfiler.StartProfile("OnDrawGizmos");
if (workItems.workItemsInProgress || isScanning) {
// If updating graphs, graph info might not be valid right now
// so just draw the same thing as last frame.
@ -780,10 +779,7 @@ public class AstarPath : VersionedMonoBehaviour {
if (debugMode == GraphDebugMode.HierarchicalNode) hierarchicalGraph.OnDrawGizmos(gizmos);
}
}
gizmos.FinalizeDraw();
AstarProfiler.EndProfile("OnDrawGizmos");
}
#if !ASTAR_NO_GUI
@ -1251,7 +1247,6 @@ public class AstarPath : VersionedMonoBehaviour {
RelevantGraphSurface.FindAllGraphSurfaces();
InitializePathProcessor();
InitializeProfiler();
ConfigureReferencesInternal();
InitializeAstarData();
@ -1333,26 +1328,6 @@ public class AstarPath : VersionedMonoBehaviour {
}
/// <summary>\endcond</summary>
/// <summary>Calls AstarProfiler.InitializeFastProfile</summary>
void InitializeProfiler () {
AstarProfiler.InitializeFastProfile(new string[14] {
"Prepare", //0
"Initialize", //1
"CalculateStep", //2
"Trace", //3
"Open", //4
"UpdateAllG", //5
"Add", //6
"Remove", //7
"PreProcessing", //8
"Callback", //9
"Overhead", //10
"Log", //11
"ReturnPaths", //12
"PostPathCallback" //13
});
}
/// <summary>
/// Initializes the AstarData class.
/// Searches for graph types, calls Awake on <see cref="data"/> and on all graphs
@ -1611,14 +1586,11 @@ public class AstarPath : VersionedMonoBehaviour {
/// <summary>
/// Scans a particular graph asynchronously. This is a IEnumerable, you can loop through it to get the progress
/// <code>
/// foreach (Progress progress in AstarPath.active.ScanAsync()) {
/// Debug.Log("Scanning... " + progress.description + " - " + (progress.progress*100).ToString("0") + "%");
/// }
/// </code>
/// You can scan graphs asyncronously by yielding when you loop through the progress.
///
/// You can scan graphs asyncronously by yielding when you iterate through the returned IEnumerable.
/// Note that this does not guarantee a good framerate, but it will allow you
/// to at least show a progress bar during scanning.
/// to at least show a progress bar while scanning.
///
/// <code>
/// IEnumerator Start () {
/// foreach (Progress progress in AstarPath.active.ScanAsync()) {
@ -1638,14 +1610,10 @@ public class AstarPath : VersionedMonoBehaviour {
/// <summary>
/// Scans all specified graphs asynchronously. This is a IEnumerable, you can loop through it to get the progress
///
/// <code>
/// foreach (Progress progress in AstarPath.active.ScanAsync()) {
/// Debug.Log("Scanning... " + progress.description + " - " + (progress.progress*100).ToString("0") + "%");
/// }
/// </code>
/// You can scan graphs asyncronously by yielding when you loop through the progress.
/// Note that this does not guarantee a good framerate, but it will allow you
/// to at least show a progress bar during scanning.
///
/// <code>
/// IEnumerator Start () {
/// foreach (Progress progress in AstarPath.active.ScanAsync()) {
@ -1999,7 +1967,7 @@ public class AstarPath : VersionedMonoBehaviour {
/// The NNConstraint can be used to specify constraints on which nodes can be chosen such as only picking walkable nodes.
///
/// <code>
/// GraphNode node = AstarPath.active.GetNearest(transform.position, NNConstraint.Default).node;
/// GraphNode node = AstarPath.active.GetNearest(transform.position, NNConstraint.Walkable).node;
/// </code>
///
/// <code>
@ -2068,20 +2036,22 @@ public class AstarPath : VersionedMonoBehaviour {
}
// Distance to the closest point on the node from the requested position
float dist = ((Vector3)nnInfo.clampedPosition-position).magnitude;
float distSqr = (nnInfo.clampedPosition-position).sqrMagnitude;
#pragma warning disable 0618
if (prioritizeGraphs && dist < prioritizeGraphsLimit) {
if (prioritizeGraphs) {
if (distSqr < prioritizeGraphsLimit*prioritizeGraphsLimit) {
#pragma warning restore 0618
// The node is close enough, choose this graph and discard all others
minDist = dist;
nearestNode = nnInfo;
nearestGraph = i;
break;
// The node is close enough, choose this graph and discard all others
minDist = distSqr;
nearestNode = nnInfo;
nearestGraph = i;
break;
}
} else {
// Choose the best node found so far
if (dist < minDist) {
minDist = dist;
if (distSqr < minDist) {
// Choose the best node found so far
minDist = distSqr;
nearestNode = nnInfo;
nearestGraph = i;
}

View File

@ -14,3 +14,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/AstarPath.cs
uploadId: 626197

View File

@ -5,9 +5,8 @@ namespace Pathfinding {
/// <summary>
/// Helper class for easily updating graphs.
///
/// The GraphUpdateScene component is really easy to use. Create a new empty GameObject and add the component to it, it can be found in Components-->Pathfinding-->GraphUpdateScene.
/// When you have added the component, you should see something like the image below.
/// [Open online documentation to see images]
/// To use the GraphUpdateScene component, create a new empty GameObject and add the component to it, it can be found under Components-->Pathfinding-->GraphUpdateScene.
///
/// The region which the component will affect is defined by creating a polygon in the scene.
/// If you make sure you have the Position tool enabled (top-left corner of the Unity window) you can shift+click in the scene view to add more points to the polygon.
/// You can remove points using shift+alt+click.
@ -32,7 +31,7 @@ namespace Pathfinding {
/// Note: The Y (up) axis of the transform that this component is attached to should be in the same direction as the up direction of the graph.
/// So if you for example have a grid in the XY plane then the transform should have the rotation (-90,0,0).
/// </summary>
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_graph_update_scene.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_graph_update_scene.php")]
public class GraphUpdateScene : GraphModifier {
/// <summary>Points which define the region to update</summary>
public Vector3[] points;
@ -218,22 +217,20 @@ namespace Pathfinding {
if (legacyMode && bounds.size.y < minBoundsHeight) bounds.size = new Vector3(bounds.size.x, minBoundsHeight, bounds.size.z);
return bounds;
} else {
if (convexPoints == null) RecalcConvex();
return GraphUpdateShape.GetBounds(convex ? convexPoints : points, legacyMode && legacyUseWorldSpace ? Matrix4x4.identity : transform.localToWorldMatrix, minBoundsHeight);
}
}
/// <summary>
/// Updates graphs with a created GUO.
/// Creates a Pathfinding.GraphUpdateObject with a Pathfinding.GraphUpdateShape
/// representing the polygon of this object and update all graphs using AstarPath.UpdateGraphs.
/// This will not update graphs immediately. See AstarPath.UpdateGraph for more info.
/// The GraphUpdateObject which would be applied by this component.
///
/// No graphs are actually updated by this function. Call AstarPath.active.UpdateGraphs and pass this object if you want that.
/// This method is useful if you want to modify the object before passing it to the UpdateGraphs function.
///
/// See: <see cref="Apply"/>
/// </summary>
public void Apply () {
if (AstarPath.active == null) {
Debug.LogError("There is no AstarPath object in the scene", this);
return;
}
public GraphUpdateObject GetGraphUpdate () {
GraphUpdateObject guo;
if (points == null || points.Length == 0) {
@ -254,7 +251,7 @@ namespace Pathfinding {
var bounds = GetBounds();
if (bounds.center == Vector3.zero && bounds.size == Vector3.zero) {
Debug.LogError("Cannot apply GraphUpdateScene, no points defined and no renderer or collider attached", this);
return;
return null;
}
guo = new GraphUpdateObject(bounds);
@ -285,8 +282,23 @@ namespace Pathfinding {
guo.modifyTag = modifyTag;
guo.setTag = setTag;
return guo;
}
AstarPath.active.UpdateGraphs(guo);
/// <summary>
/// Updates graphs with a created GUO.
/// Creates a Pathfinding.GraphUpdateObject with a Pathfinding.GraphUpdateShape
/// representing the polygon of this object and update all graphs using AstarPath.UpdateGraphs.
/// This will not update graphs immediately. See AstarPath.UpdateGraph for more info.
/// </summary>
public void Apply () {
if (AstarPath.active == null) {
Debug.LogError("There is no AstarPath object in the scene", this);
return;
}
var guo = GetGraphUpdate();
if (guo != null) AstarPath.active.UpdateGraphs(guo);
}
/// <summary>Draws some gizmos</summary>

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/GraphUpdateScene.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/GraphUpdateShape.cs
uploadId: 626197

View File

@ -2,7 +2,7 @@ using UnityEngine;
using System.Collections.Generic;
namespace Pathfinding {
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_animation_link.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_animation_link.php")]
public class AnimationLink : NodeLink2 {
public string clip;
public float animSpeed = 1;

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/AnimationLink.cs
uploadId: 626197

View File

@ -14,7 +14,7 @@ namespace Pathfinding.Util {
/// Usage:
/// - Claim a new array using <code> SomeClass[] foo = ArrayPool<SomeClass>.Claim (capacity); </code>
/// - Use it and do stuff with it
/// - Release it with <code> ArrayPool<SomeClass>.Release (foo); </code>
/// - Release it with <code> ArrayPool<SomeClass>.Release (ref foo); </code>
///
/// Warning: Arrays returned from the Claim method may contain arbitrary data.
/// You cannot rely on it being zeroed out.

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/ArrayPool.cs
uploadId: 626197

View File

@ -34,7 +34,7 @@ namespace Pathfinding {
///
/// TODO: Add field showing how many graph updates are being done right now
/// </summary>
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_astar_debugger.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_astar_debugger.php")]
public class AstarDebugger : VersionedMonoBehaviour {
public int yOffset = 5;

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/AstarDebugger.cs
uploadId: 626197

View File

@ -32,7 +32,7 @@ namespace Pathfinding {
/// when it doesn't have to.
///
/// More precisely:
/// Let C be a circle centered at the destination for the last calculated path with a radius equal to the distance to that point divided by <see cref="sensitivity"/>.
/// Let C be a circle centered at the destination for the last calculated path, with a radius equal to the distance to that point divided by <see cref="sensitivity"/>.
/// If the new destination is outside that circle the path will be immediately recalculated.
/// Otherwise let F be the 1 - (distance from the circle's center to the new destination divided by the circle's radius).
/// So F will be 1 if the new destination is the same as the old one and 0 if it is at the circle's edge.
@ -106,6 +106,10 @@ namespace Pathfinding {
public virtual void DidRecalculatePath (Vector3 destination) {
lastRepathTime = Time.time;
lastDestination = destination;
// Randomize the repath time slightly so that all agents don't request a path at the same time
// in the future. This is useful when there are a lot of agents instantiated at exactly the same time.
const float JITTER_AMOUNT = 0.3f;
lastRepathTime -= (UnityEngine.Random.value - 0.5f) * JITTER_AMOUNT * (mode == Mode.Dynamic ? maximumPeriod : period);
}
public void DrawGizmos (Vector3 position, float radius) {

View File

@ -9,3 +9,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/AutoRepathPolicy.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/BinaryHeap.cs
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/Draw.cs
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/EditorResourceHelper.cs
uploadId: 626197

View File

@ -2,7 +2,10 @@ using Pathfinding.Serialization;
namespace Pathfinding {
[JsonOptIn]
/// <summary>Defined here only so non-editor classes can use the <see cref="target"/> field</summary>
/// <summary>
/// Base class for all graph editors.
/// Defined here only so non-editor classes can use the <see cref="target"/> field
/// </summary>
public class GraphEditorBase {
/// <summary>NavGraph this editor is exposing</summary>
public NavGraph target;

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/GraphEditorBase.cs
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/GraphModifier.cs
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/GraphUpdateProcessor.cs
uploadId: 626197

View File

@ -150,7 +150,8 @@ namespace Pathfinding {
/// <param name="callback">The callback will be called once for every contour that is found with the vertices of the contour. The contour always forms a cycle.</param>
/// <param name="yMergeThreshold">Contours will be simplified if the y coordinates for adjacent vertices differ by no more than this value.</param>
/// <param name="nodes">Only these nodes will be searched. If this parameter is null then all nodes in the grid graph will be searched.</param>
public static void GetContours (GridGraph grid, System.Action<Vector3[]> callback, float yMergeThreshold, GridNodeBase[] nodes = null) {
/// <param name="connectionFilter">Allows you to disable connections between nodes. If null, no additional filtering will be done. The filter must be symmetric, so that f(A,B) == f(B,A). A contour edge will be generated between two adjacent nodes if this function returns false for the pair.</param>
public static void GetContours (GridGraph grid, System.Action<Vector3[]> callback, float yMergeThreshold, GridNodeBase[] nodes = null, System.Func<GraphNode, GraphNode, bool> connectionFilter = null) {
// Set of all allowed nodes or null if all nodes are allowed
HashSet<GridNodeBase> nodeSet = nodes != null ? new HashSet<GridNodeBase>(nodes) : null;
@ -175,6 +176,8 @@ namespace Pathfinding {
// Check if there is an obstacle in that direction
var startNeighbour = startNode.GetNeighbourAlongDirection(neighbourIndices[startDir]);
if (connectionFilter != null && startNeighbour != null && !connectionFilter(startNode, startNeighbour)) startNeighbour = null;
if ((startNeighbour == null || (nodeSet != null && !nodeSet.Contains(startNeighbour))) && !seenStates.Contains(startState)) {
// Start tracing a contour here
trace.ClearFast();
@ -190,6 +193,8 @@ namespace Pathfinding {
seenStates.Add(state);
var neighbour = node.GetNeighbourAlongDirection(neighbourIndices[dir]);
if (connectionFilter != null && neighbour != null && !connectionFilter(node, neighbour)) neighbour = null;
if (neighbour == null || (nodeSet != null && !nodeSet.Contains(neighbour))) {
// Draw edge
var d0 = neighbourIndices[dir];
@ -218,6 +223,11 @@ namespace Pathfinding {
trace.Add(graphSpacePos);
}
} else {
#if UNITY_EDITOR
if (!neighbour.HasConnectionInDirection(GridNodeBase.OppositeConnectionDirection(neighbourIndices[dir]))) {
throw new System.InvalidOperationException("Cannot calculate contour. The graph contains one-way connections. A contour is not well defined if one-way connections exist.");
}
#endif
// Move
node = neighbour;
dir = (dir + neighbourIndices.Length/2 + 1) % neighbourIndices.Length;

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/GraphUtilities.cs
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/HierarchicalGraph.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/Int3.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/ListPool.cs
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/MovementUtilities.cs
uploadId: 626197

View File

@ -15,7 +15,7 @@ namespace Pathfinding {
/// See: editing-graphs (view in online documentation for working links)
/// </summary>
[AddComponentMenu("Pathfinding/Link")]
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_node_link.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_node_link.php")]
public class NodeLink : GraphModifier {
/// <summary>End position of the link</summary>
public Transform end;

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/NodeLink.cs
uploadId: 626197

View File

@ -21,7 +21,7 @@ namespace Pathfinding {
/// See: The example scene RecastExample2 contains a few links which you can take a look at to see how they are used.
/// </summary>
[AddComponentMenu("Pathfinding/Link2")]
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_node_link2.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_node_link2.php")]
public class NodeLink2 : GraphModifier {
protected static Dictionary<GraphNode, NodeLink2> reference = new Dictionary<GraphNode, NodeLink2>();
public static NodeLink2 GetNodeLink (GraphNode node) {

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/NodeLink2.cs
uploadId: 626197

View File

@ -42,13 +42,11 @@ namespace Pathfinding {
/// Note: Usually you do not want to use this type of link, you want to use NodeLink2 or NodeLink (sorry for the not so descriptive names).
/// </summary>
[AddComponentMenu("Pathfinding/Link3")]
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_node_link3.php")]
[HelpURL("https://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_node_link3.php")]
public class NodeLink3 : GraphModifier {
protected static Dictionary<GraphNode, NodeLink3> reference = new Dictionary<GraphNode, NodeLink3>();
public static NodeLink3 GetNodeLink (GraphNode node) {
NodeLink3 v;
reference.TryGetValue(node, out v);
reference.TryGetValue(node, out NodeLink3 v);
return v;
}
@ -62,9 +60,6 @@ namespace Pathfinding {
/// </summary>
public float costFactor = 1.0f;
/// <summary>Make a one-way connection</summary>
public bool oneWay = false;
public Transform StartTransform {
get { return transform; }
}

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/NodeLink3.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/ObjectPool.cs
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/PathInterpolator.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/PathPool.cs
uploadId: 626197

View File

@ -249,7 +249,7 @@ namespace Pathfinding {
/// </summary>
public void InitializeNode (GraphNode node) {
if (!queue.AllReceiversBlocked) {
throw new System.Exception("Trying to initialize a node when it is not safe to initialize any nodes. Must be done during a graph update. See http://arongranberg.com/astar/docs/graph-updates.php#direct");
throw new System.Exception("Trying to initialize a node when it is not safe to initialize any nodes. Must be done during a graph update. See https://arongranberg.com/astar/docs/graphupdates.html#direct");
}
for (int i = 0; i < pathHandlers.Length; i++) {
@ -309,7 +309,6 @@ namespace Pathfinding {
IPathInternals ipath = (IPathInternals)path;
AstarProfiler.StartFastProfile(0);
ipath.PrepareBase(pathHandler);
// Now processing the path
@ -327,28 +326,23 @@ namespace Pathfinding {
// Prepare the path
ipath.Prepare();
AstarProfiler.EndFastProfile(0);
if (path.CompleteState == PathCompleteState.NotCalculated) {
// For visualization purposes, we set the last computed path to p, so we can view debug info on it in the editor (scene view).
astar.debugPathData = ipath.PathHandler;
astar.debugPathID = path.pathID;
AstarProfiler.StartFastProfile(1);
// Initialize the path, now ready to begin search
ipath.Initialize();
AstarProfiler.EndFastProfile(1);
// Loop while the path has not been fully calculated
while (path.CompleteState == PathCompleteState.NotCalculated) {
// Do some work on the path calculation.
// The function will return when it has taken too much time
// or when it has finished calculation
AstarProfiler.StartFastProfile(2);
ipath.CalculateStep(targetTick);
AstarProfiler.EndFastProfile(2);
targetTick = System.DateTime.UtcNow.Ticks + maxTicks;
@ -371,7 +365,6 @@ namespace Pathfinding {
// Cleans up node tagging and other things
ipath.Cleanup();
AstarProfiler.StartFastProfile(9);
if (path.immediateCallback != null) path.immediateCallback(path);
@ -386,7 +379,6 @@ namespace Pathfinding {
// Will advance to ReturnQueue
ipath.AdvanceState(PathState.ReturnQueue);
AstarProfiler.EndFastProfile(9);
#if UNITY_2017_3_OR_NEWER
profilingSampler.End();
#endif
@ -435,7 +427,6 @@ namespace Pathfinding {
// The path we are currently calculating
Path p = null;
AstarProfiler.StartProfile("Path Queue");
// Try to get the next path to be calculated
bool blockedBefore = false;
@ -448,15 +439,11 @@ namespace Pathfinding {
}
if (p == null) {
AstarProfiler.EndProfile();
yield return null;
AstarProfiler.StartProfile("Path Queue");
}
}
AstarProfiler.EndProfile();
AstarProfiler.StartProfile("Path Calc");
IPathInternals ip = (IPathInternals)p;
@ -479,14 +466,9 @@ namespace Pathfinding {
long startTicks = System.DateTime.UtcNow.Ticks;
long totalTicks = 0;
AstarProfiler.StartFastProfile(8);
AstarProfiler.StartFastProfile(0);
//Prepare the path
AstarProfiler.StartProfile("Path Prepare");
ip.Prepare();
AstarProfiler.EndProfile("Path Prepare");
AstarProfiler.EndFastProfile(0);
// Check if the Prepare call caused the path to complete
// If this happens the path usually failed
@ -496,37 +478,27 @@ namespace Pathfinding {
astar.debugPathID = p.pathID;
// Initialize the path, now ready to begin search
AstarProfiler.StartProfile("Path Initialize");
ip.Initialize();
AstarProfiler.EndProfile();
// The error can turn up in the Init function
while (p.CompleteState == PathCompleteState.NotCalculated) {
// Do some work on the path calculation.
// The function will return when it has taken too much time
// or when it has finished calculation
AstarProfiler.StartFastProfile(2);
AstarProfiler.StartProfile("Path Calc Step");
ip.CalculateStep(targetTick);
AstarProfiler.EndFastProfile(2);
AstarProfiler.EndProfile();
// If the path has finished calculation, we can break here directly instead of sleeping
// Improves latency
if (p.CompleteState != PathCompleteState.NotCalculated) break;
AstarProfiler.EndFastProfile(8);
totalTicks += System.DateTime.UtcNow.Ticks-startTicks;
// Yield/sleep so other threads can work
AstarProfiler.EndProfile();
yield return null;
AstarProfiler.StartProfile("Path Calc");
startTicks = System.DateTime.UtcNow.Ticks;
AstarProfiler.StartFastProfile(8);
// Cancel function (and thus the thread) if no more paths should be accepted.
// This is done when the A* object is about to be destroyed
@ -549,20 +521,17 @@ namespace Pathfinding {
// Cleans up node tagging and other things
ip.Cleanup();
AstarProfiler.EndFastProfile(8);
// Call the immediate callback
// It needs to be stored in a local variable to avoid race conditions
var tmpImmediateCallback = p.immediateCallback;
if (tmpImmediateCallback != null) tmpImmediateCallback(p);
AstarProfiler.StartFastProfile(13);
// It needs to be stored in a local variable to avoid race conditions
var tmpOnPathPostSearch = OnPathPostSearch;
if (tmpOnPathPostSearch != null) tmpOnPathPostSearch(p);
AstarProfiler.EndFastProfile(13);
// Push the path onto the return stack
// It will be detected by the main Unity thread and returned as fast as possible (the next late update)
@ -570,7 +539,6 @@ namespace Pathfinding {
ip.AdvanceState(PathState.ReturnQueue);
AstarProfiler.EndProfile();
// Wait a bit if we have calculated a lot of paths
if (System.DateTime.UtcNow.Ticks > targetTick) {

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs
uploadId: 626197

View File

@ -49,6 +49,8 @@ namespace Pathfinding {
}
try {
((IPathInternals)path).AdvanceState(PathState.Returning);
// Return the path
((IPathInternals)path).ReturnPath();
} catch (System.Exception e) {

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/PathReturnQueue.cs
uploadId: 626197

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3b0dcc63072f14901912b26d84677525
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/PathfindingTagMask.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/StackPool.cs
uploadId: 626197

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/ThreadControlQueue.cs
uploadId: 626197

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/WindowsStoreCompatibility.cs
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs
uploadId: 626197

View File

@ -513,6 +513,17 @@ namespace Pathfinding {
/// <summary>Closest point on the surface of this node to the point p</summary>
public abstract Vector3 ClosestPointOnNode(Vector3 p);
/// <summary>Checks if point is inside the node when seen from above</summary>
public virtual bool ContainsPoint (Int3 point) {
return ContainsPoint((Vector3)point);
}
/// <summary>Checks if point is inside the node when seen from above.</summary>
public abstract bool ContainsPoint(Vector3 point);
/// <summary>Checks if point is inside the node in graph space</summary>
public abstract bool ContainsPointInGraphSpace(Int3 point);
/// <summary>
/// Hash code used for checking if the gizmos need to be updated.
/// Will change when the gizmos for the node might change.
@ -578,6 +589,8 @@ namespace Pathfinding {
/// See: <see cref="RemoveConnection"/>
///
/// Note: If you modify this array or the contents of it you must call <see cref="SetConnectivityDirty"/>.
///
/// May be null if the node has no connections.
/// </summary>
public Connection[] connections;
@ -622,7 +635,7 @@ namespace Pathfinding {
}
public override bool ContainsConnection (GraphNode node) {
for (int i = 0; i < connections.Length; i++) if (connections[i].node == node) return true;
if (connections != null) for (int i = 0; i < connections.Length; i++) if (connections[i].node == node) return true;
return false;
}
@ -740,34 +753,6 @@ namespace Pathfinding {
}
}
/// <summary>Checks if point is inside the node when seen from above</summary>
public virtual bool ContainsPoint (Int3 point) {
return ContainsPoint((Vector3)point);
}
/// <summary>
/// Checks if point is inside the node when seen from above.
///
/// Note that <see cref="ContainsPointInGraphSpace"/> is faster than this method as it avoids
/// some coordinate transformations. If you are repeatedly calling this method
/// on many different nodes but with the same point then you should consider
/// transforming the point first and then calling ContainsPointInGraphSpace.
/// <code>
/// Int3 p = (Int3)graph.transform.InverseTransform(point);
///
/// node.ContainsPointInGraphSpace(p);
/// </code>
/// </summary>
public abstract bool ContainsPoint(Vector3 point);
/// <summary>
/// Checks if point is inside the node in graph space.
///
/// In graph space the up direction is always the Y axis so in principle
/// we project the triangle down on the XZ plane and check if the point is inside the 2D triangle there.
/// </summary>
public abstract bool ContainsPointInGraphSpace(Int3 point);
public override int GetGizmoHashCode () {
var hash = base.GetGizmoHashCode();

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Nodes/GraphNode.cs
uploadId: 626197

View File

@ -7,7 +7,7 @@ using System.Collections.Generic;
namespace Pathfinding {
/// <summary>
/// Provides additional traversal information to a path request.
/// See: turnbased (view in online documentation for working links)
/// See: traversal_provider (view in online documentation for working links)
/// </summary>
public interface ITraversalProvider {
bool CanTraverse(Path path, GraphNode node);
@ -68,7 +68,7 @@ namespace Pathfinding {
/// <summary>
/// Provides additional traversal information to a path request.
/// See: turnbased (view in online documentation for working links)
/// See: traversal_provider (view in online documentation for working links)
/// </summary>
public ITraversalProvider traversalProvider;
@ -108,12 +108,23 @@ namespace Pathfinding {
public string errorLog { get; private set; }
/// <summary>
/// Holds the path as a Node array. All nodes the path traverses.
/// Holds the path as a <see cref="GraphNode"/> list.
///
/// These are all nodes that the path traversed, as calculated by the pathfinding algorithm.
/// This may not be the same nodes as the post processed path traverses.
///
/// See: <see cref="vectorPath"/>
/// </summary>
public List<GraphNode> path;
/// <summary>Holds the (possibly post processed) path as a Vector3 list</summary>
/// <summary>
/// Holds the (possibly post-processed) path as a Vector3 list.
///
/// This list may be modified by path modifiers to be smoother or simpler compared to the raw path generated by the pathfinding algorithm.
///
/// See: modifiers (view in online documentation for working links)
/// See: <see cref="path"/>
/// </summary>
public List<Vector3> vectorPath;
/// <summary>The node currently being processed</summary>
@ -150,7 +161,7 @@ namespace Pathfinding {
protected bool hasBeenReset;
/// <summary>Constraint for how to search for nodes</summary>
public NNConstraint nnConstraint = PathNNConstraint.Default;
public NNConstraint nnConstraint = PathNNConstraint.Walkable;
/// <summary>
/// Internal linked list implementation.
@ -272,8 +283,8 @@ namespace Pathfinding {
/// }
/// </code>
///
/// Note: Do not confuse this with AstarPath.WaitForPath. This one will wait using yield until it has been calculated
/// while AstarPath.WaitForPath will halt all operations until the path has been calculated.
/// Note: Do not confuse this with AstarPath.BlockUntilCalculated. This one will wait using yield until it has been calculated
/// while AstarPath.BlockUntilCalculated will halt all operations until the path has been calculated.
///
/// Throws: System.InvalidOperationException if the path is not started. Send the path to Seeker.StartPath or AstarPath.StartPath before calling this function.
///
@ -432,15 +443,6 @@ namespace Pathfinding {
}
}
/// <summary>
/// State of the path in the pathfinding pipeline.
/// Deprecated: Use the <see cref="Pathfinding.Path.PipelineState"/> property instead
/// </summary>
[System.Obsolete("Use the 'PipelineState' property instead")]
public PathState GetState () {
return PipelineState;
}
/// <summary>Causes the path to fail and sets <see cref="errorLog"/> to msg</summary>
public void FailWithError (string msg) {
Error();
@ -448,28 +450,6 @@ namespace Pathfinding {
else errorLog = msg;
}
/// <summary>
/// Logs an error.
/// Deprecated: Use <see cref="FailWithError"/> instead
/// </summary>
[System.Obsolete("Use FailWithError instead")]
protected void LogError (string msg) {
Log(msg);
}
/// <summary>
/// Appends a message to the <see cref="errorLog"/>.
/// Nothing is logged to the console.
///
/// Note: If AstarPath.logPathResults is PathLog.None and this is a standalone player, nothing will be logged as an optimization.
///
/// Deprecated: Use <see cref="FailWithError"/> instead
/// </summary>
[System.Obsolete("Use FailWithError instead")]
protected void Log (string msg) {
errorLog += msg;
}
/// <summary>
/// Aborts the path because of an error.
/// Sets <see cref="error"/> to true.
@ -577,7 +557,7 @@ namespace Pathfinding {
private bool releasedNotSilent;
/// <summary>
/// Claim this path (pooling).
/// Increase the reference count on this path by 1 (for pooling).
/// A claim on a path will ensure that it is not pooled.
/// If you are using a path, you will want to claim it when you first get it and then release it when you will not
/// use it anymore. When there are no claims on the path, it will be reset and put in a pool.
@ -611,22 +591,13 @@ namespace Pathfinding {
}
/// <summary>
/// Releases the path silently (pooling).
/// Deprecated: Use Release(o, true) instead
/// </summary>
[System.Obsolete("Use Release(o, true) instead")]
internal void ReleaseSilent (System.Object o) {
Release(o, true);
}
/// <summary>
/// Releases a path claim (pooling).
/// Removes the claim of the path by the specified object.
/// When the claim count reaches zero, the path will be pooled, all variables will be cleared and the path will be put in a pool to be used again.
/// Reduces the reference count on the path by 1 (pooling).
/// Removes the claim on the path by the specified object.
/// When the reference count reaches zero, the path will be pooled, all variables will be cleared and the path will be put in a pool to be used again.
/// This is great for performance since fewer allocations are made.
///
/// If the silent parameter is true, this method will remove the claim by the specified object
/// but the path will not be pooled if the claim count reches zero unless a Release call (not silent) has been made earlier.
/// but the path will not be pooled if the claim count reches zero unless a non-silent Release call has been made earlier.
/// This is used by the internal pathfinding components such as Seeker and AstarPath so that they will not cause paths to be pooled.
/// This enables users to skip the claim/release calls if they want without the path being pooled by the Seeker or AstarPath and
/// thus causing strange bugs.
@ -684,13 +655,9 @@ namespace Pathfinding {
}
// Ensure capacities for lists
AstarProfiler.StartProfile("Check List Capacities");
if (path.Capacity < count) path.Capacity = count;
if (vectorPath.Capacity < count) vectorPath.Capacity = count;
AstarProfiler.EndProfile();
c = from;
for (int i = 0; i < count; i++) {

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Path.cs
uploadId: 626197

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/PathHandler.cs
uploadId: 626197

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/RVO/RVOAgent.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/RVO/RVOCoreObstacle.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/RVO/RVOCoreSimulator.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/RVO/RVOLine.cs
uploadId: 626197

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/RVO/RVOQuadtree.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Serialization/JsonConverters.cs
uploadId: 626197

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Serialization/JsonSerializer.cs
uploadId: 626197

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Serialization/SimpleJsonReplacement.cs
uploadId: 626197

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Serialization/SimpleZipReplacement.cs
uploadId: 626197

View File

@ -130,7 +130,7 @@ namespace Pathfinding.Serialization {
// Fortunately it should be extremely rare to have to serialize references to unity objects in a standalone player.
var realPath = UnityEditor.AssetDatabase.GetAssetPath(obj);
var match = System.Text.RegularExpressions.Regex.Match(realPath, @"Resources/(.*?)(\.\w+)?$");
if (match != null) path = match.Groups[1].Value;
if (match.Success) path = match.Groups[1].Value;
#endif
QuotedField("Name", path);
output.Append(", ");
@ -259,7 +259,7 @@ namespace Pathfinding.Serialization {
var arr = Array.CreateInstance(tp.GetElementType(), ls.Count);
ls.ToArray().CopyTo(arr, 0);
return arr;
} else if (Type.Equals(tp, typeof(Mesh)) || Type.Equals(tp, typeof(Texture2D)) || Type.Equals(tp, typeof(Transform)) || Type.Equals(tp, typeof(GameObject))) {
} else if (typeof(UnityEngine.Object).IsAssignableFrom(tp)) {
return DeserializeUnityObject();
} else {
var obj = populate ?? Activator.CreateInstance(tp);

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/Serialization/TinyJson.cs
uploadId: 626197

View File

@ -10,7 +10,7 @@ namespace Pathfinding {
[System.Serializable]
/// <summary>Stores editor colors</summary>
public class AstarColor {
public class AstarColor : ISerializationCallbackReceiver {
public Color _SolidColor;
public Color _UnwalkableNode;
public Color _BoundsHandles;
@ -71,7 +71,7 @@ namespace Pathfinding {
/// It is a bit ugly though, but oh well.
/// </summary>
public void PushToStatic (AstarPath astar) {
_AreaColors = _AreaColors ?? new Color[1];
_AreaColors = _AreaColors ?? new Color[0];
SolidColor = _SolidColor;
UnwalkableNode = _UnwalkableNode;
@ -82,6 +82,15 @@ namespace Pathfinding {
AreaColors = _AreaColors;
}
public void OnBeforeSerialize () {}
public void OnAfterDeserialize () {
// Patch bad initialization code in earlier versions that made it start out with a single transparent color.
if (_AreaColors != null && _AreaColors.Length == 1 && _AreaColors[0] == default) {
_AreaColors = new Color[0];
}
}
public AstarColor () {
// Set default colors
_SolidColor = new Color(30/255f, 102/255f, 201/255f, 0.9F);
@ -161,7 +170,7 @@ namespace Pathfinding {
/// GraphMask mask1 = GraphMask.FromGraphName("My Grid Graph");
/// GraphMask mask2 = GraphMask.FromGraphName("My Other Grid Graph");
///
/// NNConstraint nn = NNConstraint.Default;
/// NNConstraint nn = NNConstraint.Walkable;
///
/// nn.graphMask = mask1 | mask2;
///
@ -255,13 +264,29 @@ namespace Pathfinding {
/// Equivalent to new NNConstraint ().
/// This NNConstraint has settings which works for most, it only finds walkable nodes
/// and it constrains distance set by A* Inspector -> Settings -> Max Nearest Node Distance
///
/// Deprecated: Use <see cref="NNConstraint.Walkable"/> instead. It is equivalent, but the name is more descriptive.
/// </summary>
[System.Obsolete("Use NNConstraint.Walkable instead. It is equivalent, but the name is more descriptive")]
public static NNConstraint Default {
get {
return new NNConstraint();
}
}
/// <summary>
/// An NNConstraint which filters out unwalkable nodes.
/// This is the most commonly used NNConstraint.
///
/// It also constrains the nearest node to be within the distance set by A* Inspector -> Settings -> Max Nearest Node Distance
/// </summary>
public static NNConstraint Walkable {
get {
return new NNConstraint();
}
}
/// <summary>Returns a constraint which does not filter the results</summary>
public static NNConstraint None {
get {
@ -918,7 +943,7 @@ namespace Pathfinding {
/// GraphMask mask1 = GraphMask.FromGraphName("My Grid Graph");
/// GraphMask mask2 = GraphMask.FromGraphName("My Other Grid Graph");
///
/// NNConstraint nn = NNConstraint.Default;
/// NNConstraint nn = NNConstraint.Walkable;
///
/// nn.graphMask = mask1 | mask2;
///
@ -977,13 +1002,16 @@ namespace Pathfinding {
return value.ToString();
}
/// <summary>A bitmask containing the given graph index.</summary>
public static GraphMask FromGraphIndex(uint graphIndex) => new GraphMask(1 << (int)graphIndex);
/// <summary>
/// A bitmask containing the first graph with the given name.
/// <code>
/// GraphMask mask1 = GraphMask.FromGraphName("My Grid Graph");
/// GraphMask mask2 = GraphMask.FromGraphName("My Other Grid Graph");
///
/// NNConstraint nn = NNConstraint.Default;
/// NNConstraint nn = NNConstraint.Walkable;
///
/// nn.graphMask = mask1 | mask2;
///
@ -1181,13 +1209,21 @@ namespace Pathfinding {
/// <summary>Internal state of a path in the pipeline</summary>
public enum PathState {
/// <summary>Path has been created but not yet scheduled</summary>
Created = 0,
/// <summary>Path is waiting to be calculated</summary>
PathQueue = 1,
/// <summary>Path is being calculated</summary>
Processing = 2,
/// <summary>Path is calculated and is waiting to have its callback called</summary>
ReturnQueue = 3,
Returned = 4
/// <summary>The path callback is being called right now (only set inside the callback itself)</summary>
Returning = 4,
/// <summary>The path has been calculated and its callback has been called</summary>
Returned = 5,
}
/// <summary>State of a path request</summary>
public enum PathCompleteState {
/// <summary>

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Core/astarclasses.cs
uploadId: 626197

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,14 @@
fileFormatVersion: 2
guid: 83e896564a2899b02a27f2b09e299ea7
guid: 6ba61cf4da975e3a4841ad6fcf64443c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Documentation/documentation.html
uploadId: 626197

View File

@ -1,7 +1,14 @@
fileFormatVersion: 2
guid: 2cbc8d35fbfe3949da32f54e59b9712d
guid: 8f0149786b9343f00a47a692754a8f8c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Documentation/documentation.pdf
uploadId: 626197

View File

@ -5,3 +5,10 @@ TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Documentation/index.md
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Editor/AIBaseEditor.cs
uploadId: 626197

View File

@ -10,3 +10,10 @@ MonoImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Editor/AILerpEditor.cs
uploadId: 626197

View File

@ -6,3 +6,10 @@ MonoImporter:
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Editor/AnimationLinkEditor.cs
uploadId: 626197

View File

@ -78,6 +78,9 @@ namespace Pathfinding {
// Make sure all references are set up to avoid NullReferenceExceptions
script.ConfigureReferencesInternal();
// Hide position/rotation/scale tools for the AstarPath object. Instead, OnSceneGUI will draw position tools for each graph
Tools.hidden = true;
Undo.undoRedoPerformed += OnUndoRedoPerformed;
// Search the assembly for graph types and graph editors
@ -126,6 +129,7 @@ namespace Pathfinding {
SetAstarEditorSettings();
CheckGraphEditors();
Tools.hidden = false;
SaveGraphsAndUndo();
@ -204,14 +208,6 @@ namespace Pathfinding {
}
#if ProfileAstar
if (GUILayout.Button("Log Profiles")) {
AstarProfiler.PrintResults();
AstarProfiler.PrintFastResults();
AstarProfiler.Reset();
}
#endif
// Handle undo
SaveGraphsAndUndo(storedEventType, storedEventCommand);
@ -404,7 +400,7 @@ namespace Pathfinding {
// Check if the latest version is newer than this version
if (FullyDefinedVersion(newVersion) > FullyDefinedVersion(AstarPath.Version)) {
GUIUtilityx.PushTint(Color.green);
if (GUILayout.Button((beta ? "Beta" : "New") + " Version Available! "+newVersion, thinHelpBox, GUILayout.Height(15))) {
if (GUILayout.Button((beta ? "Beta" : "New") + " Version Available! "+newVersion, thinHelpBox, GUILayout.Height(16))) {
Application.OpenURL(AstarUpdateChecker.GetURL("download"));
}
GUIUtilityx.PopTint();
@ -706,7 +702,7 @@ namespace Pathfinding {
if (script.data.cacheStartup && script.data.file_cachedStartup != null) {
GUIUtilityx.PushTint(Color.yellow);
GUILayout.Label("Startup cached", thinHelpBox, GUILayout.Height(15));
GUILayout.Label("Startup cached", thinHelpBox, GUILayout.Height(16));
GUILayout.Space(20);
GUIUtilityx.PopTint();
}
@ -754,16 +750,6 @@ namespace Pathfinding {
GUILayout.EndHorizontal();
if (script.data.data_cachedStartup != null && script.data.data_cachedStartup.Length > 0) {
EditorGUILayout.HelpBox("Storing the cached starup data on the AstarPath object has been deprecated. It is now stored " +
"in a separate file.", MessageType.Error);
if (GUILayout.Button("Transfer cache data to separate file")) {
script.data.file_cachedStartup = SaveGraphData(script.data.data_cachedStartup);
script.data.data_cachedStartup = null;
}
}
GUILayout.Space(5);
GUILayout.BeginHorizontal();
@ -901,8 +887,15 @@ namespace Pathfinding {
alwaysVisibleArea.End();
}
readonly string[] heuristicOptimizationOptions = new [] {
"None",
"Random (low quality)",
"RandomSpreadOut (high quality)",
"Custom"
};
void DrawHeuristicOptimizationSettings () {
script.euclideanEmbedding.mode = (HeuristicOptimizationMode)EditorGUILayout.EnumPopup(new GUIContent("Heuristic Optimization"), script.euclideanEmbedding.mode);
script.euclideanEmbedding.mode = (HeuristicOptimizationMode)EditorGUILayout.Popup(new GUIContent("Heuristic Optimization"), (int)script.euclideanEmbedding.mode, heuristicOptimizationOptions);
EditorGUI.indentLevel++;
if (script.euclideanEmbedding.mode == HeuristicOptimizationMode.Random) {
@ -1185,7 +1178,12 @@ namespace Pathfinding {
GraphEditor result;
if (graphEditorTypes.ContainsKey(graphType)) {
result = System.Activator.CreateInstance(graphEditorTypes[graphType].editorType) as GraphEditor;
var graphEditorType = graphEditorTypes[graphType].editorType;
result = System.Activator.CreateInstance(graphEditorType) as GraphEditor;
// Deserialize editor settings
var editorData = (graph as IGraphInternals).SerializedEditorSettings;
if (editorData != null) Pathfinding.Serialization.TinyJsonDeserializer.Deserialize(editorData, graphEditorType, result, script.gameObject);
} else {
Debug.LogError("Couldn't find an editor for the graph type '" + graphType + "' There are " + graphEditorTypes.Count + " available graph editors");
result = new GraphEditor();
@ -1195,6 +1193,7 @@ namespace Pathfinding {
result.fadeArea = new FadeArea(graph.open, this, level1AreaStyle, level1LabelStyle);
result.infoFadeArea = new FadeArea(graph.infoScreenOpen, this, null, null);
result.target = graph;
result.OnEnable();
return result;
}
@ -1331,11 +1330,6 @@ namespace Pathfinding {
script.data.DeserializeGraphs(bytes);
// Make sure every graph has a graph editor
CheckGraphEditors();
// Deserialize editor settings
for (int i = 0; i < graphEditors.Length; i++) {
var data = (graphEditors[i].target as IGraphInternals).SerializedEditorSettings;
if (data != null) Pathfinding.Serialization.TinyJsonDeserializer.Deserialize(data, graphEditors[i].GetType(), graphEditors[i], script.gameObject);
}
} catch (System.Exception e) {
Debug.LogError("Failed to deserialize graphs");
Debug.LogException(e);

View File

@ -5,3 +5,10 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
AssetOrigin:
serializedVersion: 1
productId: 87744
packageName: A* Pathfinding Project Pro
packageVersion: 4.2.19
assetPath: Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs
uploadId: 626197

Some files were not shown because too many files have changed in this diff Show More