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

网站开发前端就业前景二级域名分发平台

网站开发前端就业前景,二级域名分发平台,网页设计尺寸标准,seo优化方案模板目录 一、前提 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/530604/

相关文章:

  • 环保网站建设情况报告wordpress 漂亮的博客
  • 电子商务网站建设与管理试卷windows 2008 wordpress
  • 化妆品网站模板公司网站公司哪家好
  • 汉服网站设计目的视觉上体验的网站
  • 学校网站策划书有什么可以做建筑模型的网站
  • 免费做网站有哪些家上海哪家公司做网站好
  • 企业网站的意义wordpress怎么设置伪静态页面
  • php+ajax网站开发典型实例pdf网络经营范围包括哪些
  • 国税局网站里打印设置如何做做网站的客户需求报告答案
  • 网站显示乱码怎么办啊公众号投票怎么制作
  • 做振动盘的企业网站军事新闻视频在线观看
  • 做海报图片去哪个网站找 知乎做平台网站怎么赚钱
  • oss静态网站托管业务平台低价
  • .net php开发网站开发网页内容有哪些
  • 百度网站置顶怎么做优秀网站分析案例
  • 中山网站建设思公司起名在线生成器
  • wordpress 建站主题中学网站建设书
  • 网站建设登录页面怎么写wordpress默认登陆地址修改
  • 如何用wampp 做网站冒用公司名做网站
  • 丹东手机网站新颖的互联网公司名字
  • 网站文明专栏建设wordpress返回404
  • 深圳做h5网站设计软件开发 上海
  • 长治网站建设龙采科技技术支持延吉最好的网站建设公司
  • 宁波网站制作网站网站建站平台公司
  • 网站项目的介绍类似58的推广平台有哪些平台
  • 网站建设有用吗制作重庆城市的网页
  • 在线教育网站有哪些商场设计理念
  • 云南网站建设哪家公司好南城网站建设多少钱
  • 网站雪花特效网页制作与设计专业
  • 大连企业招聘网站西安网站设计 牛人网络