A* Pathfinding Project  4.0.3
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 you are using Recast graphs.

See Also
Saving and Loading Graphs

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

See Also
Compiler Directives