Unity3D + Glass Development Kit Preview
Asked Answered
B

1

10

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 )

Benignant answered 13/12, 2013 at 20:42 Comment(0)
D
13

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.

Discontent answered 24/12, 2013 at 17:39 Comment(3)
Thanks for the reply, but Unity misses out on the rest of the features of the GDK such as the touchpad and voice intents. I'm looking for a way to compile with the GDK instead of API 15. Figured all I would have to do was download it, but Unity doesn't add it to the target menu.Benignant
I edited my answer to add information on how to use the touchpad and register a voice intent.Discontent
Thanks! AndroidInput.touchCountSecondary solves most of my issues.Benignant

© 2022 - 2024 — McMap. All rights reserved.