Intel® Developer Zone offers tools and how-to information for cross-platform app development, platform and technology information, code samples, and peer expertise to help developers innovate and succeed. Join our communities for Android, Internet of Things, Intel® RealSense™ Technology, and Windows to download tools, access dev kits, share ideas with like-minded developers, and participate in hackathon’s, contests, roadshows, and local events.
Unity* software is one of the most popular game engines for the mobile environment (Android* and iOS*). As technology improves, especially as GPUs in mobile chips get faster, players are demanding more 3D mobile games. According to Wikipedia, there are over 1.2 billion of mobile deivce users in China in 2014, nearly 4 times than that of United States. With the growth in mobile market share of Intel® processors in the People’s Republic of China (PRC), developers want to know how to enable their Unity-based games for Intel® Architecture for Android phones/tablets in China, a unique booming market where apps are not distributed/sold by Google Play. China has some unique situations that require game developer to take certain measures when developing and porting their games for this most active and fast growing country, which this article covers.
General porting guide for a Unity game
It is very easy to port an ARM*-based Unity game to Intel Architecture if the game doesn’t have any plugins. We will show you how.
First, download Unity version 4.6 or higher. Then open your game project with Unity. On the File menu select Build settings. You will see the window below.
After choosing Android and clicking the Player Settings button, a configuration window will be shown as below.
Make sure the device filter option is FAT or x86, then build the project. You will get an APK that supports x86 native.
However, we’re not done yet. Mobile games are a bit more complicated because they contain third-party plugins for performing various tasks.
The impact of plugins on game porting
Most Unity games use plugins that provide added-value services. In China, the plugins tend to be the ones listed below:
|Plugin Type ||Comments |
|Payment SDK ||In-app purchase |
|Security SDK ||Protect app with re-compile |
|Exception Handler SDK ||Debug game in remote |
|Advertisement SDK ||Provide advertisement within game |
|Platform Access SDK ||Provide account services for online game |
|Data Statistics SDK ||Collect users’ information to back-end server |
|Cloud Push SDK ||Push notification from server |
More complete descriptions of each plugin are given below.
Many independent software vendors (ISV) focus on revenue collection in game development. An effective way to do this is in-app purchase, which needs a payment plugin. In China there are lots of payment vendors such as Alipay, Caifutong, and Wechat payment to name a few. Additionally, telecom operators, such as China Mobile, China Unicom, and China Telecom, have payment plugins for ISVs.
Most game code for the Android platform is developed in Java*, which is compiled to a DEX file. This file is an easy target of a decompile hack. Because of this, security for --- is needed. Ijiami, 360, Bangbang, and Najia are all main security vendors in China market.
Exception handler SDK
Debugging software for Android usually includes checking logs, setting breakpoints, and observing running parameters step by step. When a crash happens, it can be more effective to dump the crash information, especially after the application has been released. This information includes platform registers and the call stack. Some ISVs combine exception handlers to games for tracking log information. So, as an example, PRC ISV Tencent developed an SDK called Bugly that integrates all Tencent’s applications and games exceptions.
Like in-app purchases, advertising integrated in games is yet another business model for game developers to make revenue.
Platform Access SDK
Many games, especially online games, want players to have accounts in order to record their progress and store scores in back servers. So popular PRC account systems like QQ and Wechat have been embedded in games.
Data Statistics SDK
Data Statistic SDKs record game player’s statistics, which developers can then use to optimize and modify the game.
Cloud Push SDK
This SDK sends notification to users from a server.
When enabling an Android game to x86 native, all related SDKs must be ported to x86 before plug into Unity; otherwise, the game will not run well on Intel Architecture-based platforms.
Here is good example for Unity plugin to enable to x86 native.
Case Study: We Fire
We Fire is the first 3D first person shooter mobile game from Tencent Lightspeed Studio. It has more than 137 million registered users and 26 million active users per month; it’s one of the most popular mobile games in China right now.
The ARM version of We Fire has 11 libraries in the lib/armeabi-v7a folder, but only three libraries, libunity.so, libmain.so, and libmono.so, are actually responsible for the gaming rendering. The others are all plugins. For example, libtpnsSecurity.so is a plugin SDK for game security with anti-theft and anti-reverse engineering.
First, we need to port all libraries in this folder to x86 native like below.
However, the game crashed when this APK was installed on x86 Android 5.0 due to a libwbsafeedit library, which is an ARM binary hidden in the assets folder.
When we enabled this library for x86 as below, the app worked well on an Intel Architecture-based device.
But not all libraries can be ported to x86 native easily. Take the library libBugly.so as an example. It is responsible for tracing crash information and uploading it to the cloud. It also gets stack information from NDK C/C++ code, so it involves ASM functions of the system platform. Before it can be compiled to x86 native successfully, we had to rewrite parts of the code from ARM to x86.
We ran some performance comparisons between the ARM version and x86 version on an x86 device. The results are below.
After porting, the average power consumption improved about 10% than when running via Native Bridge. And the CPU and RAM utilization rates were reduced 26% and 21% respectively.
In addition, the APK size of Fat (ARM+x86) is just 9 MB more than the ARM version.
|We Fire ||APK Size |
|ARM ||234M |
|Fat (X86+ARM) ||243M |
Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark* and MobileMark*, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. Configurations: [describe config + what test used + who did testing]. For more information go to http://www.intel.com/performance.
For creating Android games with Unity, you’ll see a performance benefit on Intel Architecture by porting to x86 native. But the Unity engine is not the only thing that must be ported; all the related plugins must be ported as well. If you want to successfully port a Unity game to x86 native, you should do the porting for these plugins in advance.
About the Author
Tao Peng is a software apps engineer in the Intel Software and Services Group. He currently focuses on gaming enabling and performance optimization, in particular on Android mobile platforms.