是否可以将MS Band与Unity独立Windows版本一起使用? [英] Is it possible to use MS Band with Unity standalone Windows build?

查看:125
本文介绍了是否可以将MS Band与Unity独立Windows版本一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出最快的方法将数据从MS Band 2获取到具有VR支持的Unity独立Windows版本中.我可以在Win10笔记本电脑上构建和运行SDK示例应用程序,并且它们可以正常工作.

我尝试了各种方法,从将Microsoft.Band.DLL作为托管插件导入Unity到尝试将Band DLL包装在本机插件中.但是,我还没有找到一种使这项工作可行的方法.我开始怀疑,由于多种原因,我根本无法使Band DLL与独立的Windows版本一起使用.

当我尝试将Band DLL用作托管插件时,Unity不支持Band DLL所需的C#4.当我尝试创建本机DLL时,无法确定如何在VS2015中创建可与Band SDK一起使用的项目,也无法更改示例项目以输出DLL而不是应用程序.当我尝试一个可以输出DLL的新项目并尝试安装Microsoft.Band NuGet程序包时,它告诉我即使SDK版本是10 *,我的项目仍以"native,Version = v0.0"为目标./p>

理想情况下,有一种方法可以在Unity的Band DLL中包含所需的DLL,并且我可以将其作为托管插件进行访问.但是,我什至乐于将C ++文件包装在外部"C"中,并制作一个单独的函数来返回Band中的每个数据.

我只是对通用Windows概念不够熟悉,不知道是否有一种方法可以使它与Unity独立Windows版本一起使用,或者是否有意阻止这种方式工作.由于它们都在同一台计算机上运行,​​因此似乎应该可行.

我的后备计划是编写一个通用Windows应用程序,该应用程序读取设备数据,并连接到Unity独立Windows应用程序以对其进行访问.究竟是通过本地文件,网络连接还是远程服务器,这是另一个问题.

解决方案

最好的方法是使用 C ++ 周围制作包装器 MS Band ,但这不是选项,因为 Microsoft 没有 MS Band的 C ++ API ,并且自2015年底以来,程序员的网站上充斥着要求 C ++ 的程序员的请求,但他们忽略了. 您仍然有4个其他选项可能会起作用,也可能不会起作用.

  1. 尝试 Unity C#5.0和6.0集成 https://bitbucket.org/alexzzzz/unity-c-5.0 -and-6.0-integration/src 这将使您在Unity中使用C#> 4.页面上如何设置它.

  2. 使用本地进程间通信. 使用C#制作一个控制台插件,并使用 Visual Studio 而不是 Unity 将项目构建为C#.将其编译为 exe 而不是 DLL ,并将其命名为 MSBandLIC.exe .在此程序中编写与 MS Band 通信的所有代码.

    从您的 Unity 程序

    开始程序 MSBandLIC.exe .

    然后,您可以使用匿名管道与Unity中的MSBandLIC.exe进行通信.该代码很长,但易于编写.这是Microsoft提供的有关如何或执行此操作的链接. https://msdn.microsoft.com/en-us/library/bb546102.aspx

  3. TCP控制台插件

    使用C#制作控制台插件,并使用 Visual Studio (而不是 Unity )将项目构建为C#.将其编译为 exe 而不是 DLL ,并将其命名为MSBandTCP.exe.

    从您的 Unity 程序

    开始程序 MSBandTCP.exe 程序.编写所有代码以与 MS Band 通信>在此程序中,然后创建一个监听端口 5550 TCP 服务器.

    Unity 端,使用TCP通过端口 5550 连接到您的本地计算机,您可以在其中进行通信 >,并从MS Band接收信息.

  4. 反向工程 API ,并使用您需要从MS Band访问的功能制作简单的 API .看来 MS Band 通过蓝牙与计算机/手机通信. Bluefruit LE Sniffer Wireshark 应该可以帮助您实现.

    这是怎么做的:

    从MS Band API中选择所需的功能. 编写一个不带Unity的C#应用​​,该应用在2秒内循环所有消息的同时将消息发送到MS Band.使用 Bluefruit LE Sniffer Wireshark 查看从 Windows MS Band 的消息. MS Band 应该响应,如果可以,但是发送的内容已被加密,请使用 JustDecompile 来反编译API和图的DLL部分了解API如何反编译从 MS Band 接收到的字节.然后,您可以从收集的信息中重建自己的API.

I'm trying to figure out the quickest way to get data from the MS Band 2 into a Unity standalone Windows build with VR support. I'm able to build and run the SDK sample apps on my Win10 laptop, and they work.

I've tried various things, ranging from importing the Microsoft.Band.DLL into Unity as a managed plugin, to trying to wrap the Band DLL in a native plugin. However, I have not found a way to make this work. I'm starting to suspect that I simply will not be able to get the Band DLL to work with a standalone Windows build, for a number of reasons.

When I try to use the Band DLL as a managed plugin, Unity doesn't support C# 4 which is required by the Band DLL. When I try to create a native DLL, I can't figure out how to create a project in VS2015 that will work with the Band SDK, and I can't change the sample projects to output a DLL instead of an app. When I try a new project that can output a DLL, and try to install the Microsoft.Band NuGet package, it tells me that my project targets 'native,Version=v0.0' even though the SDK version is 10.*.

Ideally, there would be a way to include required DLLs with the Band DLL in Unity, and I could access it as a managed plugin. But I'd even be happy with wrapping a C++ file in extern "C" and making a separate function to return each piece of data from the Band.

I simply am not familiar enough with the Universal Windows concept to know if there is a way to make it work with a Unity standalone Windows build, or if it is intentionally prevented from working that way. Since they both run on the same machine, it seems like this should be possible.

My fallback plan is to write a Universal Windows app that reads the device data, and have that connect to the Unity standalone Windows app to give access to it. Whether that's through a local file, network connection, or remote server is another problem altogether.

解决方案

The best way of doing this is to use C++ to make a wrapper around the MS Band but that is not an option in this case because Microsoft does not have a C++ API for MS Band and their website is full of requests from programmers asking for C++ support since late 2015, which they ignored. You still have 4 other options that may or may not work.

  1. Try Unity C# 5.0 and 6.0 Integration https://bitbucket.org/alexzzzz/unity-c-5.0-and-6.0-integration/src This will let you use C# >4 with Unity. How to Set it up is on the page.

  2. Use Local Interprocess Communication. Make a console plugin with C# and build the project as C# with Visual Studio instead of Unity. Compile it to exe instead of DLL and call it MSBandLIC.exe. Write all your code that communicates with the MS Band in this program.

    Start the MSBandLIC.exe program from your Unity program.

    You can then use Anonymous Pipes to communicate with the MSBandLIC.exe from Unity. The code is long but easy to write. Here is a link from Microsoft on how or do this. https://msdn.microsoft.com/en-us/library/bb546102.aspx

  3. TCP Console Plugin

    Make a console plugin with C# and build the project as C# with Visual Studio instead of Unity. Compile it to exe instead of DLL and call it MSBandTCP.exe.

    Start the MSBandTCP.exe program from your Unity program.Write all your code communicates with the MS Band in this program then create a TCP server listening to port 5550.

    On Unity side, use TCP to connect to your local machine with port 5550 and there you can communicate and receive information from MS Band.

  4. Reverse-Engineer the API and make your simple API with the functions you need to access from the MS Band. It looks like MS Band communicates with computer/mobile phones through Bluetooth. Bluefruit LE Sniffer and Wireshark should help you accomplish this.

    How do this:

    Choose a functions that you need from the MS Band API. Write a C# App without Unity that sends a message to the MS Band in while loop everything 2 seconds. Use Bluefruit LE Sniffer and Wireshark to see what message is going from Windows to the MS Band. MS Band should respond, if it does but what it sent is encrypted, use JustDecompile to de-compile the DLL part of the API and figure out how the API de-compiles bytes it receives from the MS Band. You can then reconstruct your own API from what information you gathered.

这篇关于是否可以将MS Band与Unity独立Windows版本一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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