Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Unity for Architectural Visualization

You're reading from  Unity for Architectural Visualization

Product type Book
Published in Sep 2013
Publisher Packt
ISBN-13 9781783559060
Pages 144 pages
Edition 1st Edition
Languages
Author (1):
Stefan Boeykens Stefan Boeykens
Profile icon Stefan Boeykens

Switching between materials


An interesting interactive option you can provide to clients is choosing between different material finishes. A good example of such a system can be found in Autodesk Showcase at http://www.autodesk.com/products/showcase/overview, which displays a popup list of material thumbnails in a very realistic real-time view of a design.

We follow a similar approach as the camera switcher, by setting up a list of alternative textures and using the OnGUI() method to display a button to switch between alternative materials. It is important to prepare the list of textures on beforehand. This is shown in the following code:

using UnityEngine;
using System.Collections;
public class switchMaterials : MonoBehaviour {
  public Material[] materialList;
  public GameObject target;
  private int index = 0;
  void OnGUI(){
    if (GUI.Button(new Rect(5,5,100,24), "Next Material")){
      index = (index + 1) % materialList.Length;
        target.renderer.material = materialList[index...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $19.99/month. Cancel anytime}