1:解决相机反转问题,和安装后点击同意相机权限后,相机没有打开。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using static UnityEngine.UI.AspectRatioFitter;
//挂载到RawImage上即可
[RequireComponent(typeof(AspectRatioFitter))]
[RequireComponent(typeof(RawImage))]
public class Webcam_Test : MonoBehaviour
{
private WebCamTexture cameraTexture;
//加上AspectRatioFitter组件调整画面尺寸
RawImage background;
AspectRatioFitter fit;
bool isFirst = true;
IEnumerator Start()
{
InitData();
yield return StartCoroutine(InitCameraCor());
}
// Update is called once per frame
void Update()
{
//调整rawimage
AdjustmentRawimage();
//处理用户首次同意权限后相机没有打开的问题
if (cameraTexture == null)
{
var isOk = Application.HasUserAuthorization(UserAuthorization.WebCam);
if (Application.platform =&#