Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 )

like image 291
Brent Marshall Avatar asked Dec 13 '13 20:12

Brent Marshall


1 Answers

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

  • Set the minimum SDK to API 15, set the orientation to Landscape Left, and (optionally) set the Game view size to 640 x 360.

  • Unity's Input.gyro will work with the gyroscope in the device, so you can rotate the Unity camera to match for fun augmented reality effects.

  • Use the AndroidInput.GetSecondaryTouch() static method to get touches on the Glass touchpad. You can easily detect individual taps on with AndroidInput.touchCountSecondary.

  • Like any GDK app, you will need to create the resource files for the voice trigger. Create the folder "Assets/Plugins/Android/res/xml" and the voice trigger XML resource. Mine is:

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.

like image 162
robterrell Avatar answered Nov 13 '22 00:11

robterrell