Locate Metaio camera on a fixed position as gui texture + Display one object from the scene through that Metaio camera - unity3d

1) I am a beginner to using Metaio in Unity, so my question is that is it possible to include two cameras on my scene: one is the main for 3D environment, and another camera (metaio camera) to display objects from Unity on the real world that must be fixed on the top wright corner as UI plane of my game. Something like in the picture below:
2) Also, how to display on the metaio camera view on the scene instead of displaying all scene objects as shown in the image below, although I only attached one cube object under metaio tracker:
Any help or answers gratefully received.
Thanks.

you have to attach an script to that plain and add the code bellow to that script:
void Start() {
WebCamTexture webcamTexture = new WebCamTexture();
renderer.material.mainTexture = webcamTexture;
webcamTexture.Play();
}
if you working for android you have to add camera permission to you manifest.
i think you need to work on it, because it doesnt work simply and you have to play with camera positions and to work very well.
this link shows you camera options that you have in unity:
http://docs.unity3d.com/ScriptReference/WebCamTexture.html

Related

Unity and Hololens, how to remove the black mesh renderer?

I created a simple application which is a menu containing 4 scenes.
Scene 1 = using Vuforia, I replace marker with a 3D Object
Scene 2 = you can click on a 3D sphere
Scene 3 = you can click on a 3D cube
Scene 4 = you can click on a 3D pyramid
My main focus is the scene 1 actually.
The problem
When I was testing this scene in Unity, Vuforia would automatically use my webcam as a camera and I could look for marker as you can see on this picture :
Now I got my hands on the Hololens, using Holographic Remoting Player I keep getting this mesh on every scene I created (this picture is from Unity but I see the exact same in the Hololens) :
What I've tried
I looked for element using a Mesh Renderer but if I disable this element, then the virtual element doesn't appear anymore.
I also took a look into the MRTK Camera settings which are the following ones :
But I can't figure out how to remove this black backgrounded mesh that appears on each of my scene.
I figured it out, so for anyone having this issue the solution is to set the MRTK - Spatial Awarness display option to Occlusion

How to pause/freeze the AR Camera in Unity?

I am making an AR game with Unity.
I used the commonly used 'Time.timeScale = 1' to use the pause function,
This will turn the AR Camera screen into a black screen.
In addition, if you add the ar occlusion manager function in this state, the app will be down with the screen bugged.
When using AR Camera, what is the proper way to implement temporary suspension?
The actual screen you are viewing with AR camera should be seen with a frozen frame.
Please
What i would do is take a camera shot
ScreenCapture.CaptureScreenshot("TestImage.png");
then i would display it on a raw image
RawImage qrRenderer;
renderer.material.mainTexture = webcamTexture;
you can at that time disable youe camera
camera.enabled = false;

Unity Video Player

I am failing at playing a simple video under unity free 2017.1.0f3 personal
I am working on a game and I'd like to play an introduction video at the start of the app. Then move onto the login screen whenever the player clicks it.
I have created a video player object, dragged and dropped the video clip (mp4) into the video clip field of the object.
I then attached the object to the camera. In the script attached to the camera I created a public VideoPlayer that I have populated with the video player object.
I then execute :
void Awake ()
{
VideoPlayer.Play();
}
But nothing happens.
Perhaps it should be executed within a separate thread (coroutine)? I tried but did not work either.
Any help please?
Provided you filled the right settings, if it still doesn't play but you get no error, no freeze, no nothing.
Trying restarting Unity.
(I struggled for 45 min trying to figure out why my video wouldn't play anymore until I restarted Unity and it magically reworked)
did you check if the Video can be played back by unity?
put a quad in front of your camera, put a videocomponent on there, check Loop and playonAwake, hit Play and see if it works.
GameObjectWithPlayerComponentAttatched.GetComponent<VideoPlayer>().Play();
should work fine
Did you assign the RenderTexture?
What I do is create a RenderTexture, then assign it to the videoplayer, then add a Raw Image and then give it the RenderTexture in the Texture field.
You should uncheck play onAwake if you want to play it at a certain point, instead of videoplayer.Play, use videoPlayer.
Prepare and prepareCompleted Play the video.
Like this:
private void Start()
{
videoPlayer.prepareCompleted += VideoPlayer_prepareCompleted;
videoPlayer.Prepare();
}
private void VideoPlayer_prepareCompleted(VideoPlayer source)
{
videoPlayer.Play();
}
Video Player has three modes: Render Texture -- and then you need to select a RenderTexture to render to, Material Override -- and then it needs a mesh to write to its material, and Camera -- then you need to assign a camera and select to render to the near or far plane.
To have the camera feature work automatically, you need to instantiate the VideoPlayer script on the camera object itself.
Follow these steps to play a video using unity's VideoPlayer component:
Create a plane, under 3d Objects.
Add a VideoPlayer component to that plane.
Set render mode as Material Override.
Drag the mesh renderer component of the plane to the videoplayer's renderer field.
Select a video clip to play and enable play on awake.
Press play in the editor window.

Unity 3D with Vuforia AR: Adding a Gameobject to ARCamera View

I am using Unity3D with extension of Vuforia. I am working on Cylindrical targets. When ARCamera detects the image and starts the augmentation, I want to show my GameObject (.fbx file, imported into the Meshes folder and created a Prefab out of it) on the screen.
I am working in Unity C#.
I attached a script to the GameObject and initialized it DefaultTrackableEventHandler Script. When I run it in Unity and the camera starts, I don't see my object in the Game View. Whereas in Screen View, I see that bottle (Prefab) rotating.
make sure the camera, or the focal point has your object in sight, when i tried vuforia, rotate your card slowly 360° to see if you can see the object, also your object could be far above what you expect, I would recommend very long expanded cubes in the 3 axis, to get the reference in the augmented world, then move from there

Open device camera for iPhone and Android in Unity3d

I am working an application in which i need to open device camera in full view and i am making this app for both iOS and Android. So can any one tell me that how can i open full screen device camera in Unity for all devices Android and iPhone.
This will be great help for me. Thanks in advance.
After some more digging on Google and Official docs. I got solution which I am going to share with you , It help someone .. someday..
1.Create New Project.
2.Select Main Camera in GameObject and change Transform via Inspector
Position X= -90 Y=785 Z=0 Rotation X=90 Y=90 Z=0 Scale X=1 Y=1 Z=1
3.Now go to GameObject — > Create Other — > Plane.
4.Select Main Camera in GameObject and
4.1 change Transform via Inspector
Position X=0 Y=0 Z=0 Rotation X=0 Y=0 Z=0 Scale X=100 Y=100 Z=100
4.2 change Tag=Player
Now create a c# script with name “CameraController” and replace the code with below one
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour
{
public WebCamTexture mCamera = null;
public GameObject plane;
// Use this for initialization
void Start ()
{
Debug.Log ("Script has been started");
plane = GameObject.FindWithTag ("Player");
mCamera = new WebCamTexture ();
plane.renderer.material.mainTexture = mCamera;
mCamera.Play ();
}
// Update is called once per frame
void Update ()
{
}
}
5.Finally save and Drag this Script file onto “Plane” GameObject
Note - you may see preview rotated in Unity Game view but on RealDevice it works well. tested on iPhone5 and Android - Nexus 5.
Here is the snap shot how it comes if you change rotation angle to 180:
If you mean you want to use the camera to take and save photographs, I'd recommend Prime31's iOS and Android plugins. Unfortunately the Etcetera plugin is us$65 per platform, but I've used them both and they work great.
http://u3d.as/content/prime31/i-os-etcetera-plugin/2CU
http://u3d.as/content/prime31/android-etcetera-plugin/2CY
If you just want to show the camera's live output inside of your app's scene, you can create a plane and use a WebCamTexture to display the camera's live video output.
http://docs.unity3d.com/Documentation/ScriptReference/WebCamTexture.html
There is a toolkit available to open the device camera in unity for iOS and Android called CameraCaptureKit - (https://www.assetstore.unity3d.com/en/#!/content/56673)
All the source is available and it has a plain and and simple plug'n'play demo as with Unity UI - it solves some of the obstacles involved with taking still images using the camera on your device.
Since the WebCamTexture is a generic solution to taking still images it doesn't enable sharpening of the images, the quality as well is more low-res on iOS since it uses a configuration for capturing real time video.
If you want to turn on flash / torch there you can do that with the toolkit.
There is a great plugin named Android native Camera for open device camera and save the video or image inside the device. Currently, it works only android.