I am unsure wether this is a feature not completely implemented. If it’s bugged or it’s just missing a working example how to use it.
According to the documentation (http://docs.unity3d.com/Manual/UnityRemote4.html ) and the Sourcecode of Unity Remote in the Asset Store it should be possible to transfer the recorded images from the mobile device to the Desktop Computer.
I have tried to change the Unity Remote form the Asset Store so it transfers the images without a request from the client side. However even then i am unable to capture the data on the desktop computer.
Does anybody know how to implement this? Is a change in the Unity Remote required?
Anybody from Unity maybe? I dont not want to believe that there was no testing of the unity remote. I just wonder why no use examples are delivered with the unity remote package in the asset store.
if you want to use WebCamTexture to get the camera stream from a device connected through Unity Remote, then you must initalize it through the constructor as it is stated in the documentation.
You can apply following script to any object in your scene. Ensure you created a suitable material which is assigned to your object and to the script too! It should list you all cameras available on your host and remote clients!
using System;
using UnityEngine;
using System.Collections.Generic;
public class WebCamBehaviour : MonoBehaviour
{
/// <summary>
/// Meta reference to the camera
/// </summary>
public Material CameraMaterial = null;
/// <summary>
/// The number of frames per second
/// </summary>
private int m_framesPerSecond = 0;
/// <summary>
/// The current frame count
/// </summary>
private int m_frameCount = 0;
/// <summary>
/// The frames timer
/// </summary>
private DateTime m_timerFrames = DateTime.MinValue;
/// <summary>
/// The selected device index
/// </summary>
private int m_indexDevice = -1;
/// <summary>
/// The web cam texture
/// </summary>
private WebCamTexture m_texture = null;
// Use this for initialization
void Start()
{
if (null == CameraMaterial)
{
throw new ApplicationException("Missing camera material reference");
}
Application.RequestUserAuthorization(UserAuthorization.WebCam);
}
void OnGUI()
{
if (m_timerFrames < DateTime.Now)
{
m_framesPerSecond = m_frameCount;
m_frameCount = 0;
m_timerFrames = DateTime.Now + TimeSpan.FromSeconds(1);
}
++m_frameCount;
GUILayout.Label(string.Format("Frames per second: {0}", m_framesPerSecond));
if (m_indexDevice >= 0 && WebCamTexture.devices.Length > 0)
{
GUILayout.Label(string.Format("Selected Device: {0}", WebCamTexture.devices[m_indexDevice].name));
}
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
GUILayout.Label("Has WebCam Authorization");
if (null == WebCamTexture.devices)
{
GUILayout.Label("Null web cam devices");
}
else
{
GUILayout.Label(string.Format("{0} web cam devices", WebCamTexture.devices.Length));
for (int index = 0; index < WebCamTexture.devices.Length; ++index)
{
var device = WebCamTexture.devices[index];
if (string.IsNullOrEmpty(device.name))
{
GUILayout.Label("unnamed web cam device");
continue;
}
if (GUILayout.Button(string.Format("web cam device {0}{1}{2}",
m_indexDevice == index
? "["
: string.Empty,
device.name,
m_indexDevice == index ? "]" : string.Empty),
GUILayout.MinWidth(200),
GUILayout.MinHeight(50)))
{
m_indexDevice = index;
// stop playing
if (null != m_texture)
{
if (m_texture.isPlaying)
{
m_texture.Stop();
}
}
// destroy the old texture
if (null != m_texture)
{
UnityEngine.Object.DestroyImmediate(m_texture, true);
}
// use the device name
m_texture = new WebCamTexture(device.name);
// start playing
m_texture.Play();
// assign the texture
CameraMaterial.mainTexture = m_texture;
}
}
}
}
else
{
GUILayout.Label("Pending WebCam Authorization...");
}
}
// Update is called once per frame
private void Update()
{
if (null != m_texture &&
m_texture.didUpdateThisFrame)
{
CameraMaterial.mainTexture = m_texture;
}
}
}
I am developing an AR app with Vuforia. I am using remote app with the aim of playing the camera from my android on the unity editor for testing.
I used the suggested script but I didn’t make it work. The “suitable material” you talk about, does it need to have any particular property?
Do I need to modify the profiles.xml file in order to add my android device camera? Where can I get the camera name?
This is what I get when I use remote with my phone. However there’s no way to make the stream change when I click any of the options. I already added “Remote Camera 0” and “Remote Camera 1” to profiles.xml file but still doesn’t work. Any suggestion?
Right, vuforias has it, but it only shows the laptop camera. Until you press play button, the camera and the pc are not connected, so Unity editor doesn’t recognise the device camera.
right, sorry i mixed something up. i’m using a separate usb camera for vuforia testing. if you find a way of using unity remote i’d be interested as well but i currently lack the time to test that.
I experimented the same problem, so I tried it using an Android cam as “webcam to PC” app (DroidCam, IP WebCam and WO WebCam), Vuforia recognized them as Camera Devices, but DroidCam and WO WebCam didn’t run in background, so I can’t use Unity remote simultaneously (my AR app works fine in PC with my Android camera as webcam). IP WebCam does run in background, but Unity didn’t found the device when Vuforia called it.
I used the suggested script, I can enable my android cameras in Vuforia using the Background Plane material (AR Camera>Camera>BackgroundPlane) only after playing my app, but Vuforia continued using my laptop camera to search for the Trackable image.
Maybe using Android Stuido for enabling device cameras…or another third party software to connect android camera as webcam.
This sounds like a bug, could someone please create a bug report with a minimal reproducible so we can test and see the behaviour? A good description would help a lot too! When submitted please add the bug number in this thread so we don’t miss it
same here!
I’m using Vuforia with DroidCam to read the phone’s camera and it works great.
However I also want to use Unity Remote at the same time to read the phone’s GPS coordinates.
But whenever I enable Unity Remote DroidCam no longer works and vice versa! I need both Unity Remote and DroidCam at the same time
If you want to use Iphone cam to switch PC webcam in unity AR project(by Vuforia). I’ve tried using IVCam, and it works. The process is pretty simple. Just download IVCam APP on your Iphone and client software for windows(iVCam - Use mobile phone as a PC webcam | E2ESOFT). Then open the APP and the client software to try to change your Iphone as webcam. Then open your unity AR project, you will find that the camera list has two cameras you can choose. There is one thing you have to notice. The original screen view is reverse, but you still can switch the screen view directly by the button on IVCam APP after you rating the APP. Good luck!
Hello everyone The script which is shared by David Berger works well, if you are seeing black screen, it may happen because your phone does not acces to the App ( in my case it is Unity Remote 5 ). So, I allowed my phone camera to work for Unity Remote 5 from my phone Settings and it works well.
Hello Berilyalcinkayaa, thanks for your information, I used that script to allow IPhone to use the camera success, but after that still black screen once the play mode. Any other setting in need? thanks a lot for your sharing.