Unity* and Android Build for Intel® Architecture

Abhishek Nandy
CEO at Geek Monkey Studios

In this article I will try to cover Unity* with steps for Android* build for Intel® architecture.

Please note that an intermediate level and familiarity with C# and Unity is expected to be able to follow along with this tutorial.

Let's get started

Why Unity?

  • Unity as a game engine is easy to learn and work upon to bring your ideas to action
  • It supports C#, JavaScript*, and boo
  • It allows you to develop once and deploy to multiple targets

Unity and Intel

At Unite 2014 there came a big occasion when there was a pact between Intel and Unity to support x86 build for Unity. Starting at Unity 4.6, there is now built-in support for the x86 platform.

Getting the resources

Unity - link to download:

https://unity3d.com/get-unity/download (target the latest build)

Resources Unity and Intel - link for resources to refer to for this tutorial:

https://software.intel.com/en-us/articles/unity

Get going at Intel® Developer Zone

What are the advantages of Intel Developer Zone? There are multiple advantages, most importantly that there are more open source tools, code resources to help you get started, and a separate game dev track.

To get going on the Intel Developer Zone, we will need to do two things:

  1. Register
  2. Get going at Game Dev track https://software.intel.com/en-us/gamedev

 

Let's get going in Unity

Importing Assets:

Walkthrough:

Below we have added the balls in the scene:

I used Touch Script (https://www.assetstore.unity3d.com/en/#!/content/7394).

Then we add the characteristic script to the balls. Below is the script needed for splitting the cubes or balls:

using TouchScript.Gestures;

public class Breaker : MonoBehaviour
{
    public Transform CubePrefab;
    public float Power = 10.0f;

    private Vector3[] directions = {
                                       new Vector3(1, -1, 1),
                                       new Vector3(-1, -1, 1),
                                       new Vector3(-1, -1, -1),
                                       new Vector3(1, -1, -1),
                                       new Vector3(1, 1, 1),
                                       new Vector3(-1, 1, 1),
                                       new Vector3(-1, 1, -1),
                                       new Vector3(1, 1, -1)
                                   };

    private void Start()
    {
        GetComponent<tapgesture>().StateChanged += HandleStateChanged;
    }

    private void HandleStateChanged(object sender, TouchScript.Events.GestureStateChangeEventArgs e)
    {
        if (e.State == Gesture.GestureState.Recognized)
        {
            if (transform.localScale.x > 0.05f)
            {
                Color color = new Color(Random.value, Random.value, Random.value);
                for (int i = 0; i < 8; i++)
                {
                    var c = Instantiate(CubePrefab) as Transform;
                    c.parent = transform.parent;
                    c.name = "Cube";
                    c.localScale = 0.5f*transform.localScale;
                    c.position = transform.TransformPoint(c.localScale.x/10.0f*directions[i]);
                    c.rigidbody.velocity = Power*Random.insideUnitSphere;
                    c.renderer.material.color = color;
                }
            }
            Destroy(gameObject);
        }
    }
}

Saving the Scene

Building the Project

Now we will check the target build for Intel x86. If we target this option, it will get created for all Android targets.

And finally, let's show how we create the APK:

Conclusion

Following the above specified steps should have set you up to create a Unity project that has been targeted for Intel architecture.

For more complete information about compiler optimizations, see our Optimization Notice.