unity 检测硬件usb 插拔操作


插件  LibUsbDotNet.dll   

网盘下载

链接: https://pan.baidu.com/s/1QoHa3sMZxAlckQJmF3mRGA 提取码: 7ybq 

安装 LibUsbDotNet_Setup.2.2.8.exe 

默认安装地址  C:\Program Files\LibUsbDotNet   中有各种usb操作c#示例

usb 插拔示例 C:\Program Files\LibUsbDotNet\Src\Test_DeviceNotify

unity应用此插件注意 api为 .net4.x 版本    在编辑器中应用时可能会报错

 

using LibUsbDotNet.DeviceNotify;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LibUsb : MonoBehaviour
{
    private IDeviceNotifier devNotifier;
    public Text text;
    delegate void AppendNotifyDelegate(string s);
    void Start()
    {
        devNotifier = DeviceNotifier.OpenDeviceNotifier();

        devNotifier.OnDeviceNotify += onDevNotify;
    }

    private void onDevNotify(object sender, DeviceNotifyEventArgs e)
    {
        text.text = e.EventType.ToString();

    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM