I've been testing out Unity for the past couple of weeks to come to terms with the development pipeline and how it integrates with Android.
Some issues have popped up, and also some solutions. Specifically, the build process and requirements to introduce plugins into Android-Unity projects is not quite straight-forward, and some steps are fairly hard to manage:
- Integrating Android resources is, as I understand it, being worked on in the beta, but not yet there in release, and resource collisions still cause problems.
- Working with Eclipse is complex, especially with regards to debugging the Java aspect of apps.
- Some people have described issues when using custom icons and the like for market apps. (e.g. http://forum.unity3d.com/threads/713...it-look-so-bad)
- Building a Unity project where a 2D Android interface is then to be integrated.
To this end, I have devised a process, which, at the moment, works well, and provides better integration with the android pipeline, as well as potentially better integration with shared Java libraries in Eclipse.
However, this process involves accessing data from the temporary folder for the Unity project, "$ProjectRoot/Temp/StagingArea", meaning it is not future-proof, as Unity Android is not a fully released product yet and subject to change.
For now, here is the solution I have constructed, in a fairly simple step-by-step manner:
Android SDK, NDK
Eclipse, configured for usage with Android
Unity Pro / Android advanced
Note: Unlike official procedures, there is no need to introduce plugin files or any Java code into the Unity assets. Under some circumstances, you may still want to import java native libraries into the Unity project, but this is not necessary.
- Set up your Unity Android project as you would normally and hit Build.
- Enter your project folder, go to Temp/StagingArea.
- Copy all project files to a new folder.
- Import this folder as a new Android project in Eclipse.
- Mark this project as a library in the properties window for the project. (Right click on the project name, go to Properties->Android and mark "Is Library".)
- Create a new Android project in Eclipse. This will constitute the Java part of your project.
- Add the Unity Android project as a library to your new project. (Right click on the project name, go to Properties->Android, select "Add...", add the project.)
- Add the classes.jar library to the Library references for your new project. (In properties, go to Java_Build_path->Libraries, select "Add External Jar...", navigate to UNITY_INSTALLATION\Editor\Data\PlaybackEngines\and roidplayer\bin and add classes.jar)
- Move the assets folder from the library project to the new project. (Android does not allow assets to be utilized in libraries, and this last step has to be repeated whenever the Unity project is rebuilt.)
- Optionally, copy the AndroidManifest file from the library project to the new project, as it contains some Unity configuration and will not be used unless moved to the executable project.
Note that you will lose the one-step build process once you begin integrating the two projects in Eclipse, as the project has to be built in Unity, the asset folder copied to Eclipse and the whole project built again. Most of this process can be automated fairly easily using scripts however.
At this point, you can instantiate an Activity as normal in Android, either by setting up a class extending UnityPlayerActivity, or rebuilding it yourself, as the source code for it is available and documented in UNITY_INSTALLATION\Editor\Data\PlaybackEngines\and roidplayer\src\com\unity3d\player. How to do this is available at http://unity3d.com/support/documenta...l/Plugins.html.
Once all of this is done, your library folder contains the assets utilized by the Unity engine (basically, the splash icon and an XML layout) and never has to be touched again. The only requirement that is posed here is that the asset folder in the new project is updated whenever the Unity project is recompiled. Any references to native libraries that need to be utilized in Unity can be managed in the new java project as in a normal Android project. Icons, debugging, signing, and other android-integration can now be managed from Eclipse.
I release this hoping it will make your integration process with Unity easier, hope you enjoy.