新增debug工具
This commit is contained in:
parent
f09bb8f282
commit
21ceeadb24
|
@ -84,4 +84,5 @@ public enum YogaEventType
|
||||||
UpdateProgress,
|
UpdateProgress,
|
||||||
ShowHint,
|
ShowHint,
|
||||||
ShowMessage,
|
ShowMessage,
|
||||||
|
ChangeCaptureCameraDevice,
|
||||||
}
|
}
|
|
@ -1,6 +1,19 @@
|
||||||
public class GlobalData : MonoSingleton<GlobalData>
|
using UnityEngine;
|
||||||
{
|
|
||||||
private PositionType position = PositionType.None;
|
|
||||||
|
|
||||||
public PositionType Position { get => position; internal set => position = value; }
|
public class GlobalData : MonoSingleton<GlobalData>
|
||||||
|
{
|
||||||
|
private PositionType _position = PositionType.None;
|
||||||
|
private int _cameraIndex = 0;
|
||||||
|
private CameraDeviceType _cameraDeviceType;
|
||||||
|
|
||||||
|
public PositionType Position { get => _position; internal set => _position = value; }
|
||||||
|
|
||||||
|
public int CameraIndex { get => _cameraIndex; internal set => _cameraIndex = value; }
|
||||||
|
public CameraDeviceType CameraDeviceType { get => _cameraDeviceType; set => _cameraDeviceType = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CameraDeviceType
|
||||||
|
{
|
||||||
|
System,
|
||||||
|
USB,
|
||||||
}
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public partial class SROptions
|
||||||
|
{
|
||||||
|
[Category("Camera Related")]
|
||||||
|
public void SetCameraIndex()
|
||||||
|
{
|
||||||
|
var devices = WebCamTexture.devices;
|
||||||
|
if (devices.Length == 0)
|
||||||
|
{
|
||||||
|
Debug.LogError("No camera detected!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GlobalData.Instance.CameraIndex++;
|
||||||
|
if (GlobalData.Instance.CameraIndex >= devices.Length)
|
||||||
|
{
|
||||||
|
GlobalData.Instance.CameraIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventManager.Instance.Dispatch(YogaEventType.ChangeCaptureCameraDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Camera Related")]
|
||||||
|
public void PrintCurrentCamera()
|
||||||
|
{
|
||||||
|
var devices = WebCamTexture.devices;
|
||||||
|
if (devices.Length == 0)
|
||||||
|
{
|
||||||
|
Debug.LogError("No camera detected!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogWarning($"Current camera: {devices[GlobalData.Instance.CameraIndex].name}");
|
||||||
|
foreach (var device in devices)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Camera: {device.name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Camera Related")]
|
||||||
|
public void SetCameraDeviceType()
|
||||||
|
{
|
||||||
|
if (GlobalData.Instance.CameraDeviceType == CameraDeviceType.System)
|
||||||
|
{
|
||||||
|
GlobalData.Instance.CameraDeviceType = CameraDeviceType.USB;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalData.Instance.CameraDeviceType = CameraDeviceType.System;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventManager.Instance.Dispatch(YogaEventType.ChangeCaptureCameraDevice);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6c3dfe47816f5d7458cb5d4a16745761
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue