Compile issues in A*Pathfinding code base

I recently purchased A*Pathfinding, and have been very impressed with the quality. I am using Unity 4, but I do not believe these issues are related to the Unity version.

Since A*Pathfinding uses methods with optional parameters I had to switch the projects in MonoDevelop to .NET 4.0. In doing so I ended up with the errors below. I then found another solution to enable optional parameters and then switched MonoDevelop projects back to .NET 3.5. The errors below disappeared even though they appear to be real problems. Can you explain what is happening, and possibly make the corrections below.

-(Int3.cs) On many occasions the code relies on an implicit conversion from Int3 to Vector3.
OLD:public static explicit operator Vector3 (Int3 ob) {
NEW:public static implicit operator Vector3 (Int3 ob) {

-(ConstantPath.cs) The compiler indicates current is not defined which appears to be true.
OLD:Debug.DrawRay (current.position,Vector3.up5,Color.cyan);
NEW://Debug.DrawRay (current.position,Vector3.up

-(GridGeneratorEditor.cs) Compiler indicates g,h,and i are not defined in class node.
OLD:Handles.Label((Vector3)node.position + Vector3.up2,"G : “+node.g+”
H : “+node.h+”
F : “+node.f+”
Position : "+node.position.ToString (),EditorStyles.whiteBoldLabel);
NEW://Handles.Label((Vector3)node.position + Vector3.up
2,"G : “+node.g+”
H : “+node.h+”
F : “+node.f+”
Position : "+node.position.ToString (),EditorStyles.whiteBoldLabel);


  1. Make sure you have the latest version of the project (3.1.4).
  2. If you are still getting errors, delete the AstarPathfindingProject folder and import again. This will help remove any old files which the UnityPackage import does not remove.

I actually just purchased/downloaded A*Pathfinding (3.14) for the first time so there is no chance of having legacy files. Again the errors seem to be correct and can be seen if you switch the MonoDevelop projects to .NET 4.0. Do the lines above still exist in the code and do you agree with the errors? I cannot explain why the errors do not show up when you compile against .NET 3.5.

Hm. Is it possible that you have added DEBUG to Unity’s list of enabled preprocessor directives (I think it can be found in Project Settings -> Player)? I do know that some code which is enabled by DEBUG has bugs similar to the ones you mention. But since people very rarely enable any preprocessor directives, and it has until Unity 4.0 not been possible to enable them project-wide, I have not done a quick fix for that small error.

Yes all the errors are in the #ifdef DEBUG sections, and yes I have DEBUG defined globally. I need DEBUG defined globally (Unity 4) as I use it in my code in the same way as you. If you could correct the errors for Christmas that would be appreciated.

I am still puzzled why the problem does not present itself when I compile against .NET 3.5. I switched to .NET 4 so that I could compile in MonoDevelop with the optional parameters (.NET 4 feature) that A*Pathfinding utilizes. Do you use the build button within MonoDevelop, and did you have to switch to .NET 4 under project options. You can rely on Unity for Compilation (Some kind of .NET2,3,4 hybrid), but I like to flush out syntax issues without leaving MonoDevelop.



I have no idea why it compiles using .Net 3.5. I use Unity for compilation myself.
Those errors will be (have been fixed in dev.) for the 3.2 release.

I think I should rename the define from DEBUG to something else, because right now, if you use DEBUG, it will use LOADS of debug stuff. That slows it down quite a lot.

Perhaps switching DEBUG to something like DEBUG_APATHFINDING would be prudent. I could see many people using the DEBUG define in their code not expecting to affect A*PATHFINDING.

Yes, something like that.