- Home /
Scripting for camera depth
Is there a way that I could change the depth of a camera by clicking on a button using scripting? As in, when I click a button, a camera view appears of my whole scene from above, showing where the player is relative to his surroundings. By appears, I either mean come to the front (change depth to a greater number), or literally appear (because it was invisible before). Please help.
Answer by shawnlehner · Jan 14, 2011 at 01:43 AM
pigi5,
Your question was a bit cryptic with how much you jumped around, but I assume you want to change the draw order of your camera to make it the visible camera. For this you can use the Camera.depth property, this is accesible from script.
I would recommend against this. If you are only wanting to view these cameras at certain points in your application you would be better off enabling them in these situations and keeping them disabled when you are not using them. Changing the draw order does not stop them for rendering, they are just overdrawn by other cameras.
well then could you tell me how to enable them and disable them in scripting or is it just Camera.enable and Camera.disable
And also could you tell me how to script for checking if I have clicked on a GUI texture or at least give me a link?
To register a click on a GUITexture you can attach a script and enter your click code in the On$$anonymous$$ouseDown() method. To disable and enable the camera you simply reference the enabled property of your specified camera. You can use the static properties of the Camera class to find your specific camera, or use some of the built in object search methods of Unity.
Answer by fireDude67 · Jan 14, 2011 at 04:55 AM
I would have one camera that is disabled (there is a check box next to the name, uncheck that) and then re-enabling it using disabledCamera.gameObject.active = true
.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Backgrounds moving at different speeds? 1 Answer
Problems implementing a 3rd person static camera 0 Answers
Loading pictures, how to hide and load in-game pictures? (details) 0 Answers
Can I have a 3d object or tk2d sprite between 2 NGUI layers? 1 Answer