androidunity-game-enginegoogle-glassgoogle-gdk

Unity3D + Glass Development Kit Preview


In Unity3D is it possible to target the Glass Development Kit (GDK) through Build Settings?

The Android API 15 + GDK have been downloaded through the Android SDK Manager. I can successfully build Glassware through Eclipse. In Unity3D, the GDK does not appear as the Minimum API Level (but API 15 does).

Example: File > Build Settings > Minimum API Level > Android Ice Cream Sandwich (API 15)

I'm assuming the Minimum API level is not the same as the build target, but is there a way to adjust the Unity3D build target?

(In the interim, we're using the GDK as an Android Plugin but it would be nice to be able to target the GDK directly )


Solution

  • Yes, I have built for Glass directly from Unity. It works pretty well.

    Plugins/Android/res/xml/my_voice_trigger.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <trigger command="PLAY_A_GAME">
    </trigger>
    

    Finally, you need to add the voice trigger to the app manifest. Copy the default AndroidManifest.xml from inside the Unity app bundle (Unity.app/Contents/PlaybackEngines/AndroidDevelopmentPlayer) to Assets/Plugins/Android and modify it to use the voice trigger XML, by putting the follow block into the activity tag:

    <intent-filter>
        <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
    </intent-filter>
    <meta-data android:name="com.google.android.glass.VoiceTrigger" android:resource="@xml/my_voice_trigger" />
    

    Building

    Plug your Google Glass into a USB cable, and "File > Build and Run" works on the device. (One note of warning: a serious 3D scene will get the GPU pretty warm.)

    Caveats

    The KeyCode enumeration doesn't include Glass keys (i.e. the camera button) so you can't catch that in Unity without writing a subclass of UnityNativeActivity.