Hi there i am new beginner in here. I hope someone will answer my question. im using orthographic projection camera with size 6.5. Camera captured the view and show into a 3d plane but the size is not right (scale for 3d plane is 1,1,1) but if i resize into (just say) 480,1,640 the view is blurry not focus. It was so different if i using my iphone device camera view so detail and focus.
Im using this script and it worked views camera into 3d plane
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 ()
{
}
}
What i want is i need my 3d plane auto scale into camera view size (iphone 6+) Please help
I searched using google, i found actually webcamtexture capture view in low resolution, it doesn’t matter how do i change the size for the plane it still capture in low resolution. Maybe some of you will help me out, I’m thinking if theres any alternative rather than using webcamtexture?
There are better solutions in the asset store for that but it’s not free tho.
Anyway when you create WebCamTexture, you can make some requests:
mCamera = new WebCamTexture (1920, 1080, 30);
You can’t ask whatever you want since it depend of the device capabilites.
AVPro Live Camera is great because instead of asking blindly for a resolution, it give you everything the device can do and you just pick one, among many others things.
Hi there, thanks for your reply. I found that the answer you give from documentation, (in my opinion) that code is talking about camera view screen display. What in my question is the 3d plane, resize into fit screen. Actually i can scale the plane into 1920,1080 but if i have phone with different resolution then the plane size wouldn’t match since im using webcamtexture, because camera view in plane as texture.
You can use an UI Raw Image to make it responsive to your screen tho.
But if you really want to keep a 3D planes, you can compute the 3D size by using Camera.ScreenToWorld
This function takes a Vector3:
X & Y are pixels units
Z is meter (3D unit), it is the distance at which you want to plane to be from the camera
You have to call this function twice (one for top-left and one for bottom-right, use Screen.Width and Screen.Height).
Then you have two 3D positions corresponding to the screen ratio and the FOV of your camera, you can compute the X a Y distance separately to scale your plane correctly.
If the ratio of your webcam texture is different from your phone screen you must apply a ratio factor by comparing them.
(Don’t forget to set your plane position at the distance you set in Z).