HTC Vive前置摄像头API(未测试)

/*WebCamTexture:网络摄像头材质
WebCamTexture.Play()  播放;
WebCamTexture.Pause()  暂停;
WebCamTexture.Stop()  停止;*/
//经测试此代码可以使用,当你绑定到游戏物体时尽可以了、
using unityEngine;
using System.Collections;
public class Test : MonoBehaviour {
public string deviceName;//这个虽然public,但无需为其绑定变量,直接运行,默认调用,显示本地摄像机的名称
WebCamTexture webCam;
  
  
// Use this for initialization
void Start () {
 WebCamDevice[] devices = WebCamTexture.devices;
 deviceName = devices[0].name;
 webCam = new WebCamTexture(deviceName, 400, 300, 12);
 renderer.material.mainTexture = webCam;
 webCam.Play();
}
  
// Update is called once per frame
void Update () {
  
}
}

上述代码,使用标准化的webcam

更多参考:unity3d 中控制手机前后摄像头切换 

 

2.steam论坛中介绍方法:

 It's all wrapped up on the SteamVR_TrackedCamera script included with the SteamVR plugin on the Unity Asset Store: http://u3d.as/content/valve-corporation/steam-vr-plugin

https://github.com/ValveSoftware/steamvr_unity_plugin/blob/master/Assets/SteamVR/Scripts/SteamVR_TrackedCamera.cs

We also include a test script to demonstrate usage:
https://github.com/ValveSoftware/steamvr_unity_plugin/blob/master/Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.cs

3. 用OpenVR的API打开,此法不是在unity环境中

4.自定义的plugin

It's a standard webcam/capture device. I'd imagine you can use the built in webcam texture system from unity to access it.
I personally use my own plugin (http://popmovie.xyz/ & https://www.assetstore.unity3d.com/#!/content/59097 ) but it's nothing special, anything that uses mediafoundation to capture webcams should be able to cope with it.

原文地址:https://www.cnblogs.com/eniac1946/p/7358481.html