GithubHelp home page GithubHelp logo

microsoft / unity-uwp-btle-sample Goto Github PK

View Code? Open in Web Editor NEW
8.0 7.0 13.0 55 KB

A sample using the Unity UWP BTLE Plugin to access BTLE functions from within a unity application.

License: MIT License

C# 100.00%

unity-uwp-btle-sample's Introduction

Note: This repo is now archived. It is still available READ ONLY for forking or historical interest.

UnityUWPBTLE

A unity project that uses a UWP BTLE plug in winmd to access windows BTLE functionality.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments. The following sections serve as guide posts to help navigate the code by explaining some of the larger systems, both how they work and how they interact.

Sample Device Note

This project is a framework for BTLE communication. As such it does not actually connect to any particular BTLE device. You will need to replace the code in the UnityUWPBTLE\Build\Scripts\SampleDevice directory with code relevant to your particular BTLE device.

Requirements

Minimum MSVS 2017 Minimum Unity 2017.3.x

Related

The plugin used in this project is can be found at Microsoft/UnityuWPBTLEPlugin

Running in Unity

The Unity sample project can be found in the UnityUWPBTLE directory. Open Unity 2017 and open the project "On Disk"

UnityUWPBTLE

The unity sample project.

UnityUWPBTLE\Build

The unity project assets

UnityUWPBTLE\Build_Scenes

The main unity scene

UnityUWPBTLE\Build\Plugins

This is where the UnityUWPBTLEPlugin.winmd plugin is placed for the project use.

UnityUWPBTLE\Build\Prefabs

A helper scrolling panel for program output

UnityUWPBTLE\Build\Scripts

Where the unity scripts are for the project

UnityUWPBTLE\Build\Scripts\SampleDevice

The location of a dummy BTLE device. Use as a guideline for your BTLE device communications.

UnityUWPBTLE\Build

This directory contains some files which will be overlapped with a Unity generated XAML project. It contains a working visual studio project solution that can be explored.

Building

From Unity, choose File->Build Settings to bring up the Build Settings window. All of the scenes in the Scenes to Build section should be checked. Choose Universal Windows Platform as the Platform. On the right side, choose "any device" as the Target device, XAML as the UWP Build Type, 10.0.16299.0 as the SDK, check "Unity C# Projects" and then click Build. Select the folder called 'UWP' and choose this folder.

After the build completes successfully, an explorer window will pop up. Navigate into the UWP folder and double-click UnityUWPBTLE.sln to launch Visual Studio. From Visual Studio, set the Configuration to Release for faster builds (doesn't use .NET Native) or Master to build the type of package the Store needs (uses .NET Native).

unity-uwp-btle-sample's People

Contributors

davidshoe avatar microsoftopensource avatar msftgits avatar stammen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-uwp-btle-sample's Issues

Could not load file or assembly 'System.Runtime.WindowsRuntime, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

This error is happening when I build the project.
OnEnumerateClicked
引发的异常:“System.IO.FileLoadException”(位于 System.Private.CoreLib.ni.dll 中)
“System.IO.FileLoadException”类型的异常在 System.Private.CoreLib.ni.dll 中发生,但未在用户代码中进行处理
Could not load file or assembly 'System.Runtime.WindowsRuntime, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

This error is happening when I click Enumerate button.
System.IO.FileLoadException
HResult=0x80131040
Message=Could not load file or assembly 'System.Runtime.WindowsRuntime, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=UnityUWPBTLEPlugin
StackTrace:
at UnityUWPBTLEPlugin.BluetoothLEHelper.d__46.MoveNext()
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at UnityUWPBTLEPlugin.BluetoothLEHelper.Init()
at UnityUWPBTLEPlugin.BluetoothLEHelper..ctor()
at UnityUWPBTLEPlugin.BluetoothLEHelper.get_Instance()
at ButtonHandlers.OnEnumerateClicked() in D:\Unity-UWP-BTLE-Sample-master\Assets\Scripts\ButtonHandlers.cs:line 129
at UnityEngine.Events.UnityEvent.Invoke()
at UnityEngine.EventSystems.ExecuteEvents.Execute[T](GameObject target, BaseEventData eventData, EventFunction`1 functor)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.