I am messing around with a possible augmented reality project utilising webcams and an oculus rift. I want to bring up overlays to the user's view, with the webcam always as the background layer. My project without Oculus enabled works fine:
![image][1]
But when I simply enable VR support (Oculus SDK) in edit -> project settings -> player, I can no longer see the webcam when i run it, neither in the scene view or through my CV1 oculus:
![image][2]
Clearly it is showing the blue background setting instead of the background texture i am telling it to in code. When I move the oculus around, at the bottom i can only just see a slither of the webcam image poking through. Is there a simple layering issue i am not aware of?
I have tried [this][3] but I couldn't get it to work - I am not sure what the settings of the "WebCam" Material that he has in his Raw Image in the inspector, and alas I do not even really know what that material is. My naive thought is that since I have set the background texture to be the webcam texture, that should handle everything:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class webCam : MonoBehaviour
{
public RawImage rawimage;
void Start()
{
GUITexture BackgroundTexture = gameObject.AddComponent();
BackgroundTexture.pixelInset = new Rect(0, 0, Screen.width, Screen.height);
WebCamDevice[] devices = WebCamTexture.devices;
WebCamTexture webcamTexture = new WebCamTexture(devices[0].name);
BackgroundTexture.texture = webcamTexture;
webcamTexture.Play();
}
}
I also tried [this][4] and [this][5] but I run into issues as they seem to be for older versions of unity that used options that no longer exist (well, were likely replaced by better ones).
I have to apologise because this is actually my first foray into Unity, so if I have missed out on fairly basic concepts then that is why. I intend to do some tutorials when I have time, but this is for a rapid prototyping project for work so I was really just hoping to get a basic demo of webcam(s) feeding into the oculus rift.
Thank you for your help
[1]: http://i.imgur.com/SFuW3MT.jpg
[2]: http://i.imgur.com/bXrqWA7.png
[3]: http://answers.unity3d.com/questions/909967/getting-a-web-cam-to-play-on-ui-texture-image.html
[4]: http://answers.unity3d.com/questions/9729/how-can-i-display-a-flat-background-2d-image-not-a.html
[5]: http://answers.unity3d.com/questions/431080/fullscreen-webcam-texture-behind-everything.html
↧