更新了网络服务接口定义
This commit is contained in:
8
Packages/Common~/Unrelease/Camera.meta
Normal file
8
Packages/Common~/Unrelease/Camera.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38cc9d14a87ac7d44a174a011663463d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Packages/Common~/Unrelease/Camera/BITKit.Camera.asmdef
Normal file
17
Packages/Common~/Unrelease/Camera/BITKit.Camera.asmdef
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "BITKit.Camera",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:be17a8778dbfe454890ed8279279e153"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c5bd1d06c6446b4695026e1a418b39d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
48
Packages/Common~/Unrelease/Camera/CameraProvider.cs
Normal file
48
Packages/Common~/Unrelease/Camera/CameraProvider.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Windows.WebCam;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public class CameraProvider : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private string cameraName;
|
||||
[SerializeField] private RenderTexture cameraTexture;
|
||||
|
||||
[SerializeField] private RawImage rawImage;
|
||||
// Start is called before the first frame update
|
||||
async void Start()
|
||||
{
|
||||
await Application.RequestUserAuthorization(UserAuthorization.WebCam);
|
||||
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
|
||||
{
|
||||
WebCamDevice[] devices = WebCamTexture.devices;//获取可用设备
|
||||
if (WebCamTexture.devices.Length <= 0)
|
||||
{
|
||||
Debug.LogError("没有摄像头设备,请检查");
|
||||
return;
|
||||
}
|
||||
BIT4Log.Log<CameraProvider>($"已获取到摄像头:{string.Join(" and ",devices.Select(x=>x.name))}");
|
||||
|
||||
string devicename =string.IsNullOrEmpty(cameraName) ? devices.First().name : cameraName;
|
||||
var webCamTexture = new WebCamTexture(devicename, 256, 256, 30)
|
||||
{
|
||||
wrapMode = TextureWrapMode.Repeat
|
||||
};
|
||||
rawImage.texture = webCamTexture;
|
||||
|
||||
webCamTexture.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
BIT4Log.Warnning<CameraProvider>("未获取到WebCam授权");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
11
Packages/Common~/Unrelease/Camera/CameraProvider.cs.meta
Normal file
11
Packages/Common~/Unrelease/Camera/CameraProvider.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39199264603eb804ea156954fe0f50ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user