-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtes.cs
61 lines (57 loc) · 1.87 KB
/
tes.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tes : MonoBehaviour
{
public string deviceName1;
WebCamTexture tex1;//接收返回的图片数据
public string deviceName2;
WebCamTexture tex2;//接收返回的图片数据
public GameObject plane1;
public GameObject plane2;
bool turn = true;
public GUISkin guiSkin;
void Start()
{
StartCoroutine(test1());
StartCoroutine(test2());
}
// Update is called once per frame
void Update()
{
plane1.GetComponent<Renderer>().material.mainTexture = turn ? tex1 : tex2;
plane2.GetComponent<Renderer>().material.mainTexture = turn ? tex2 : tex1;
}
void OnGUI()
{
GUI.skin = guiSkin;
if (GUI.Button(new Rect(20, 20, 300, 100), "翻转"))
{
turn = !turn;
}
}
IEnumerator test1()
{
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);//授权
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
WebCamDevice[] devices = WebCamTexture.devices;
deviceName1 = devices[0].name;
//设置摄像机摄像的区域
tex1 = new WebCamTexture(deviceName1, 1280, 720, 30);
tex1.Play();//开始摄像
}
}
IEnumerator test2()
{
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);//授权
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
WebCamDevice[] devices = WebCamTexture.devices;
deviceName2 = devices[1].name;
//设置摄像机摄像的区域
tex2 = new WebCamTexture(deviceName2, 640, 480, 30);
tex2.Play();//开始摄像
}
}
}