[C#] GameObject to Camera

Hey guys,

I’m trying to get this little JS snippet

private var Cam2 : Camera;
Cam2 = new GameObject("Cam2").gameObject.AddComponent(Camera);

running in C#. Doesn’t work howsoever I approach the problem, google doesnt help much. Any advice?

I’m thinking, it should look like the following.

Camera cam;

GameObject go =  new GameObject("Cam2");
cam =  go.AddComponent<Camera>();

this should do it

GameObject cam2 = new GameObject("cam2");
cam2.AddComponent<Camera>();

Thanks, they both work. THoeppners is preferred though, as you don’t have to call/access (however it is called derp) the camera in the object every time.