Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How get my smartphone device camera megapixel?

Discussion in 'Getting Started' started by sekmani52, Jul 5, 2021.

  1. sekmani52

    sekmani52

    Joined:
    Jul 27, 2016
    Posts:
    7
    I'm working with Unity C# and I'm searching for a way to find my exactly device camera megapixel, so I try first with this code:
    Code (CSharp):
    1.  static WebCamTexture backCam;
    2.  
    3. void Start()
    4. {
    5.    if (backCam == null)
    6.        backCam = new WebCamTexture();
    7.  
    8.    GetComponent<Renderer>().material.mainTexture = backCam;
    9.  
    10.    if (!backCam.isPlaying)
    11.        backCam.Play();
    12.    float h = backCam.height;
    13.    float w = backCam.width;
    14.    Debug.Log("The camera pixel is: " + (w * h)/1000000);
    15.  
    16. }
    The result of this code when I execute it in my real phone device was 0.31 however my smartphone camera is 64MP. Is there any idea to get my camera phone resolution ? Thanks.