- Home /
Change objects in scene
Hello,
First of all sorry for my bad English:-)
I have a question: I have a landscape and I would like to make a day, night and rain scene, and I would change the objects in the landscape. So I have a day scene with trees and NO bushes, and a day scene with trees AND bushes. (the same for the night and rain scene) How can I switch between that? I can make a whole new landscape (than I have 6 landscapes) but can I also make 6 buttons? (Like: choose your landscape / add bushes or not?) How can I do that? The solution (like the buttons) must be ingame, not in the scene where you can edit.
Sorry for my English:-)
Jordy
Answer by Jesse Anders · Nov 14, 2010 at 10:27 PM
You can activate/deactivate game objects via scripting, and enable/disable renderers as well. For the objects you mention, a straightforward solution would be to activate/deactivate the game objects or enable/disable the renderers as appropriate in response to 'GUI control' events.
How to handle the other effects depends on how you're handling effects such as rain and lighting, but whatever is required for those, it should be possible to implement via scripting in a similar fashion.
For information on how to access game objects in a scene, look here.
Answer by DaveA · Jan 20, 2011 at 08:07 PM
If you have a bunch of different scenes, they share some assets, but each is a different level, right? What I've done is make a GUI script with such buttons (and also listening for key events like F1-F6), and call Application.LoadLevel to switch between them. The trick is having that same script on an object in ALL the scenes.
Answer by Noah-1 · Jan 20, 2011 at 08:59 PM
oK you can do something like this:
if (GUI.Button(Rect(350,90,100,60),"{
Application.LoadLevel ("Name of your level"); (remember to add the level on the build settings)
else{
Application.LoadLevel ("The other level");
}
}
I hope it helps.