A* Pathfinding Project  3.8.6
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
Deploying for mobile

This page is about working with the A* Pathfinding Project when deploying for iPhone/Android.

Most things here apply for both iPhone and Android. But some is only relevant for iPhone since iPhone is more restrictive and thus greater care must be taken for compatibility.

How to get it working

The A* Pathfinding Project works for the most part out of the box even for iPhone. But if you are using stripping (Assembly or bytecode) you will have to locate the link.xml file, which you can find at Assets/AstarPathfindingProject/link.xml and place it at Assets/link.xml. This file will instruct the AOT (ahead-of-time) compiler not to strip out the classes mentioned in the file. If you do not do this, you might get errors in some cases, for example when attempting to use caching.

Using the micro mscorlib is not supported since that strips out too much of .Net.

If you are using the Fast But No Exceptions option, you will need to enable the ASTAR_FAST_NO_EXCEPTIONS define since some reflection code cannot be used then. If you are using the pro version, simply open the Optimizations tab in the A* Inspector, enable ASTAR_FAST_NO_EXCEPTIONS and click Apply. If you are using the free version, open the AstarData.cs script (in the Core folder) and add (or uncomment) this line at the top:

#define ASTAR_FAST_NO_EXCEPTIONS

Also do the same in JsonSerializer.cs.

This will hard-code references to the built-in graph types. If you have written any custom graph types you will have to add them to the hard-coded list defined in the variable DefaultGraphTypes in AstarData.cs.

See Also
Pathfinding.AstarData.DefaultGraphTypes

Optimize for mobile

Caching Startup is a good idea when deploying for the iPhone since that will reduce startup times, especially if using Recast graphs.

You can also check out the various options under A* Inspector -> Optimizations, they can help increase the performance in some cases.

Windows Phone 8

Microsoft apparently thought it was a great idea to ban much of the .Net 2 API from Windows Store. So there are some extra steps that need to be taken.

Enable ASTAR_NO_ZIP, then delete the AstarPathfindingProject/Plugins/DotNetZip/Pathfinding.Ionic.Zip.Reduced.dll file This will make the system not use zipping for compressing node data. This has the consequence that graphs saved to file will be a lot larger. However if you are only saving settings, then it should not matter much. After performing these steps you will need to reconfigure all your graph settings.