Hey Again everyone I am trying to create a tile builder interface and would like to have my window display the what the main camera is showing. Here’s the Code I am using currently, but all I get is a tiny Box with no image.
Thanks
private GameObject camObj;
private Camera cam;
void OnEnable(){
if (!camObj) {
SetCamera ();
}
}
void OnGUI(){
if (!camObj) {
SetCamera ();
Repaint ();
}
else {
RenderTexture tex = cam.targetTexture;
Texture img = tex as Texture;
GUILayout.BeginArea (new Rect(0,0, Screen.width,Screen.height));
GUILayout.Box (img);
GUILayout.EndArea ();
}
}
void SetCamera(){
camObj = GameObject.Find ("Main Camera");
if(camObj) cam = camObj.GetComponent<Camera>();
}