I can't use camera.pixelheight of the other camera in two cameras.

hello.
I’m making new lighting system by rendertexture.
i use two camera, one is for view, the other is for depth for light


i attached reference image.

i want “pixelSize” of light camera. So, i wrote (light camera name).pixelWidth and pixelHeight.
but output is view camera’s, not light camera’s.

//View Camera is Camera.main
//Light Camera is "lightCam"

RenderTexture rt = new Rendertexture(lightCam.GetComponent<Camera>().pixelWidth, lightCam.GetCompoent<Camera>().pixelHeight, 16, RenderTextureFormat.Depth);

but size of rendertexture is Main’s…or it is screen size…
what’s the problem?

my english is very poor, sorry
help me

I tested it again by using this code.

using UnityEngine;
using System.Collections;

public class fortest : MonoBehaviour {

    public Camera cam1;
    public Camera cam2;

    void Update (){
        print ("cam1 " + cam1.GetComponent<Camera> ().pixelWidth);
        print ("cam2 " + cam2.GetComponent<Camera> ().pixelWidth);
    }

}

i think pixelSize is Screen’s pixel.
i changed differently their Size. but output is same.

anyone know how to get camera’s pixel size?
i can calculate it by camera size. but it’s very silly. very expensive…

i want create rendertexture fit Camera View Size.

i solved it by other method.

i use values of “Camera Rect” (GetComponent ().rect), w and h.

int textureWidth = (int) (lightCam.GetComponent ().rect.width * resolution);
int textureHeight = (int) (lightCam.GetComponent ().rect.height * resolution);

i can set resolution of rendertexture