A* Pathfinding Project  3.1.4
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Enumerations Properties Groups Pages
Deploying for iphone

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

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 this line at the top:

#define ASTAR_FAST_NO_EXCEPTIONS

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 function FindGraphTypes in AstarData.cs.

Optimize for the iPhone

The iPhone, and most mobile devices have one or two cores (latest iPhone as of summer 2012 has two). It has also got quite limited memory available. If you have the Pro version of the A* Pathfinding Project, then you can go to optimizations and check the ASTAR_SINGLE_THREAD_OPTIMIZE (or "Single Core Optimize" which it was called before 3.2) checkbox, then click Apply. If you have the free version, this is hardcoded into the system.

The above change will restrict the script to only use one thread for pathfinding, by doing so, it can also apply some optimizations which reduce memory usage a bit.

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