Advertisement
selzero

Comtrolling Game Items Script 3

Sep 22nd, 2012
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class CubeColourChanger : MonoBehaviour {
  5.  
  6.     //input string to change the colour
  7.     public string sColour="white";
  8.     //the material object
  9.     public Material mMaterial;
  10.  
  11.     // Update is called once per frame
  12.     void Update () {
  13.  
  14.         //change colour depending on the input string
  15.         if(sColour== "white")
  16.         {
  17.             mMaterial.color=Color.white;
  18.         }
  19.         if(sColour== "red")
  20.         {
  21.             mMaterial.color=Color.red;
  22.         }
  23.         if(sColour== "green")
  24.         {
  25.             mMaterial.color=Color.green;
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement