当前位置: 首页 > news >正文

欧美模板网站建设网站推广计划

欧美模板网站建设,网站推广计划,深圳大型商城网站建设,无锡做网站优化价格目录 一、前提 1. unity打包android后&#xff0c;链接USB摄像头&#xff0c;需要USB权限。 二、流程 1.Unity导出android工程&#xff0c;Player配置如图&#xff1a; 2.导出android工程 3.在android工程中找到AndroidManifest.xml加入usb权限相关 <?xml version&quo…

目录


一、前提

1. unity打包android后,链接USB摄像头,需要USB权限。

二、流程

1.Unity导出android工程,Player配置如图:

2.导出android工程

3.在android工程中找到AndroidManifest.xml加入usb权限相关

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"><application android:extractNativeLibs="true"><activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:resizeableActivity="false" android:hardwareAccelerated="false"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" />//此处<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /></intent-filter><meta-data android:name="unityplayer.UnityActivity" android:value="true" /><meta-data android:name="android.notch_support" android:value="true" /></activity><meta-data android:name="unity.splash-mode" android:value="0" /><meta-data android:name="unity.splash-enable" android:value="True" /><meta-data android:name="unity.launch-fullscreen" android:value="True" /><meta-data android:name="unity.allow-resizable-window" android:value="False" /><meta-data android:name="notch.config" android:value="portrait|landscape" /></application><uses-feature android:glEsVersion="0x00020000" /><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.CAMERA" />//此处<uses-feature android:name="android.hardware.usb.host" />//此处<uses-permission android:name="android.permission.USB_PERMISSION" /><uses-feature android:name="android.hardware.camera" android:required="false" /><uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /><uses-feature android:name="android.hardware.camera.front" android:required="false" /><uses-feature android:name="android.hardware.touchscreen" android:required="false" /><uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" /><uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>

备注主要三行如下:

<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<uses-feature android:name="android.hardware.usb.host" />
<uses-permission android:name="android.permission.USB_PERMISSION" />

4.找到UnityPlayerActivity.java,在unity启动onResume方法里面新增打开USB权限设置:

private static final String TAG = "unity";private static final String ACTION_USB_PERMISSION = "com.android.usb.USB_PERMISSION";private UsbManager usbManager;private UsbDeviceConnection connection;private PendingIntent permissionIntent;private boolean permissionGranted = false;private BroadcastReceiver usbReceiver = new BroadcastReceiver() {@Overridepublic void onReceive(Context context, Intent intent) {String action = intent.getAction();Log.d(TAG, "USB设备连接有变化,链接到:"+action);if (ACTION_USB_PERMISSION.equals(action)) {synchronized (this) {unregisterReceiver(usbReceiver);UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {if (usbDevice != null) {// 用户已授权访问USB设备connectUsbDevice(usbDevice);}} else {Log.d(TAG, "用户未授权访问USB设备");
//                        requestPermission(usbDevice);}}}}};// Resume Unity@Override protected void onResume(){super.onResume();if (MultiWindowSupport.getAllowResizableWindow(this))return;mUnityPlayer.resume();openUsbDevice();}private  void openUsbDevice(){//        //获取注册usbusbManager = (UsbManager) getSystemService(Context.USB_SERVICE);IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);// 获取已连接的USB设备列表HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();if (deviceIterator.hasNext()) {UsbDevice  device = deviceIterator.next();permissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);Log.e(TAG, "getDeviceList: " + device.getVendorId()+"=="+device.getProductId());///注册广播registerReceiver(usbReceiver, filter);usbManager.requestPermission(device, permissionIntent);} else {Log.d(TAG, "没有找到已连接的USB设备");Toast.makeText(this, "没有找到已连接的USB设备", Toast.LENGTH_SHORT).show();}}private void connectUsbDevice(UsbDevice usbDevice) {if (usbDevice == null) {return;}connection = usbManager.openDevice(usbDevice);if (connection != null) {// 在此处执行USB通信操作Log.d(TAG, "USB设备已连接");Toast.makeText(this, "USB设备已连接", Toast.LENGTH_SHORT).show();} else {Log.d(TAG, "无法打开USB设备连接");Toast.makeText(this, "无法打开USB设备连接", Toast.LENGTH_SHORT).show();}}

注意:应用需要打开摄像机权限

http://www.yayakq.cn/news/76676/

相关文章:

  • 天津哪里有做网站的公司seo导航站
  • 北京软件开发培训机构wordpress手机版优化
  • 区块链交易网站建设建个什么网站赚钱
  • 网站建设 标书app程序开发用什么编程
  • 做冒菜店网站青岛北京网站建设公司哪家好
  • 南阳专业做网站公司哪家好wordpress 注册页修改
  • 什么网站可以查建设用地规划许可证动漫wordpress主题
  • 宁波网站开发公司怎么样郑州妇科医院排行榜
  • 整站优化方案宁乡小程序开发
  • 响应式布局模板网站免费下载导购网站怎么建
  • 外国网站欣赏巩义市网站建设培训班
  • 教做西餐的网站竞价代运营公司哪家好
  • 郑州市做网站公司a汉狮建宣传网站
  • 社交网站建设技术我做夫人那些年网站登录
  • 简单的网页设计网站wordpress图片像素
  • 公司宣传网站制作乐陵网站优化
  • 申请免费的个人网站网站建设需求分析调研调查表
  • 做企业的网站的如何推广法律门户网站源码
  • 响应式网站开发的特点python做网站效率
  • 整站网站优化推荐域名注册完成后怎么做网站
  • ppt设计网站网站建设公司 销量
  • 全国高端网站找客网
  • 职业教育网站平台建设公司网站建设的需求
  • 南平购物网站开发设计wordpress 博客大全
  • 网站详情一般是什么公司做整合营销的最高阶段是
  • 网站内容不显示wordpress 指定文章链接
  • 天水市秦州区建设局网站万能浏览器最新下载
  • 网站开发成本主要有哪些重庆seo整站优化
  • 网站加速器下载太原seo管理
  • 做彩票的网站有哪些是计算机网页制作工具