I made a second camera view for the inside view of my tank ( port hole type of view)
and got it to work fine. My question is how can i make a dashboard texture and have the camera view thru that.
thanks
wayne
I made a second camera view for the inside view of my tank ( port hole type of view)
and got it to work fine. My question is how can i make a dashboard texture and have the camera view thru that.
thanks
wayne
You can use a GUITexture - it is drawn in the GUILayer, in front of the camera. Draw the texture in some image editor (Photoshop is good - Unity reads PSD files directly), import to Assets, select it and click Create/GUITexture in the Project panel.
EDITED: After some tests, I found that GUITexture is very hard to adjust to a second camera. Fortunately, Unity has a good alternative: GUI.DrawTexture. This function draws over all cameras, and can easily be adjusted to any camera rect and screen resolution.
Attach the script below to the second camera, and the texture you’ve drawn to the variable texture: the script adjusts the texture to the camera rect and screen size automatically.
var texture: Texture; // drag your texture here
function OnGUI(){
var rect = camera.pixelRect; // rect.y is relative to screen bottom
rect.y = Screen.height-rect.y-rect.height; // let y relative to the top
var aspect = rect.width/rect.height; // calculate aspect
GUI.DrawTexture(rect, texture, ScaleMode.ScaleToFit, true, aspect);
}
question: when i bring the tex in and make it a gui tex it fills the whole screen. My camera is placed inside the turret object that i want the new view to be is this correct? Also the gui tex wont or cant be seen in camera two view where i want it to be. can you tell me what i did wrong. thanks wayne
– wayne57GUITexture is very hard to adjust to more than one camera. I found a easier way to do that with GUI.DrawTexture. I edited my answer to show this new approach - is much better and probably will solve your problem - take a look at the edited answer.
– aldonaletto
Just use gui.drawtexture. DO NOT use the "new" unityGui system. (ie, do NOT use OnGui.)
– Fattie