Switching Between Design Options

3m 14s

In this course, David Tracy will show you how to use Unity as an interactive architectural visualization tool.

First you will learn interfacing with Unity and how to import and export your project within Rhino and SketchUp. Then, you will learn how to use shaders, materials, textures, and lighting for your project. Finally, you will learn how to create scripts to enable you to interact with your scene.

When you are done with this course, you'll know how to navigate Unity to start building your own interactive walkthroughs and visualizations.

So now that we have the basic mechanism for controlling the visibility of each of our design options we can set up another condition. Actually what I'm gonna do is I'm gonna move this method to get the renderer components outside of this design option in both cases. Okay, alright and now I'm gonna evaluate which design options were looking at, and we're also gonna restructure the way that our algorithm's working a little bit.

So instead of doing our conditional statement first we're going to do our loop first. This way we can save a couple steps. So I'm gonna do, I'm gonna cut this paste it and I'm gonna put this condition inside our for loop in here. Okay so let's delete that. So now we have inside of our for loop here. If we press the J key, if the current object is part of design option one lets disable it. Else if, design option equals equals two.

Ren.enabled equals true and we'll do the opposite here. So I'm gonna set up this logic down here as well. So let's clean this up a little bit.

So I'm gonna copy and paste this here and I'm gonna flip these true, false. So now I can apply this script to my separate objects. So I'm gonna say the Barcelona chairs... I'm going to apply this script, furniture options to my Barcelona chair group and I'm gonna say this belongs tod design option one. Okay and I'm gonna select my core boot chair, I'm gonna apply this furniture options to it and I'm gonna say this is design option two.

So now if I save my script, replay my scene. I'm gonna hit J and that's gonna hide my option one. I'm gonna press K and that's gonna hide my option two. So I can toggle between these two design options by pressing the J and K key. You may notice though that both design options are shown when my scene first loads. So one way we can get around that is simply by copying this little chunk of code from my update loop into my start method.

So what I'm gonna do is when my scene starts I'm gonna get all of the renderers. I'm gonna loop through them, if they belong to design option one I'm gonna hide them. If they belong to design option two I'm gonna show them. So we can flip this, I'm gonna make design option one invisible at first and design option two invisible. Okay so now when I look at my scene design option two is no longer shown.

I can press the J key and then it will show up. I'll press the K key and that will make the design option one invisible.

Log in to access files

From the course:
Unity for Interactive Architectural Visualization

Level 1

Duration: 3h 3m

Author: David Tracy