在unity3d中访问Google玻璃擦拭垫 [英] accessing google glass swipe pad in unity3d

查看:83
本文介绍了在unity3d中访问Google玻璃擦拭垫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问我的unity3d项目中的玻璃擦拭垫,但是它不起作用. "KeyCode.Escape"可以向下滑动很好.但是我如何左右滑动并点击工作呢?

I am trying to access glass swipe pad in my unity3d project but it doesn't work. "KeyCode.Escape" works fine for swipe down. But how do I get swipe left right and tap working?

我在OnGUI中使用以下命令检查了"secondaryTouchEnabled",并返回"False",

I checked the "secondaryTouchEnabled" using the following in OnGUI and it returns "False",

GUI.Label (new Rect (300, 100, 200, 60), ""+AndroidInput.secondaryTouchEnabled.ToString());

它不返回"True"吗?

Shouldn't it return "True"?

如果有人可以在此处共享示例代码,那就太好了.

It would be great if someone could share an example code here.

推荐答案

问题中的GUI.Label应该与我在下面设置的两个调试字段相同.下面的代码将数据插入文本字段.

The GUI.Label in your question should work the same as the two debug fields I've set up below. The code below inserts the data into the text field.

void Update () {
#if UNITY_ANDROID
    if (Input.GetKey(KeyCode.Escape))
        Application.Quit(); // HANDLE ESCAPE

    // FINGERS
    debug1.text = "TOUCHES: " + AndroidInput.touchCountSecondary.ToString(); // FINGER TOUCHES

    // TOUCH COORDS
    string resp = "COORDS: \n";
    for (int i = AndroidInput.touchCountSecondary - 1; i > -1; i--) {
    resp += "(id: " + i;
        resp += " x: " + AndroidInput.GetSecondaryTouch(i).position.x;
        resp += " y: " + AndroidInput.GetSecondaryTouch(i).position.y;
        resp += ") \n";
    }
    debug2.text = resp;
#endif
}

如果您想执行更多高级GDK方法,则需要注册一个AndroidJavaClass并扩展UnityPlayerNativeActivity.完成后,您可以在Android中注册GestureDetector,然后使用UnityPlayer.UnitySendMessage();将结果传回Unity.这也适用于语音转录和其他GDK结果.

If you want to do more advanced GDK methods you will need to register an AndroidJavaClass and extend UnityPlayerNativeActivity. Once you do that you can register a GestureDetector in Android and pass the results back to Unity using UnityPlayer.UnitySendMessage(); This also works with Voice Transcriptions and other GDK results.

这篇关于在unity3d中访问Google玻璃擦拭垫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆