A* Pathfinding Project  4.1.18
The A* Pathfinding Project for Unity 3D
Deploying for mobile/uwp

This page is about working with the A* Pathfinding Project when deploying for iPhone/Android or UWP (Universal Windows Platform).

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.

Universal Windows Platform (UWP)

Unity for some reason refuses to include the metadata for some .dll files in the package with the UnityPackage file. To get it working on UWP you need to locate the Pathfinding.Ionic.Zip.dll file in your Unity project and make sure it is marked as being *excluded* when building for UWP. This should be the only thing you need to do to get it to work.

iPhone

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