Wednesday, 1 May 2013

ColourFilterControl script


public var cameraNormal : GameObject;
public var cameraRed : GameObject;
public var cameraBlue : GameObject;
public var cameraOrange : GameObject;
public var SWITCH_TO_NORMAL_CAMERA_TIME : float = 10;
public class ColorFilterControl extends MonoBehaviour
{
 public static var Instance : ColorFilterControl = null;
 public function SwitchToRedCamera()
 {
  CancelInvoke("SwitchToNormalCamera");
 
  cameraNormal.SetActive(false);
  cameraRed.SetActive(true);
  cameraBlue.SetActive(false);
  cameraOrange.SetActive(false);
 
  Invoke("SwitchToNormalCamera", SWITCH_TO_NORMAL_CAMERA_TIME );
 }

 public function SwitchToBlueCamera()
 {
  CancelInvoke("SwitchToNormalCamera");
 
  cameraNormal.SetActive(false);
  cameraRed.SetActive(false);
  cameraBlue.SetActive(true);
  cameraOrange.SetActive(false);
 
  Invoke("SwitchToNormalCamera", SWITCH_TO_NORMAL_CAMERA_TIME );
 }

 public function SwitchToOrangeCamera()
 {
  CancelInvoke("SwitchToNormalCamera");
 
  cameraNormal.SetActive(false);
  cameraRed.SetActive(false);
  cameraBlue.SetActive(false);
  cameraOrange.SetActive(true);
 
  Invoke("SwitchToNormalCamera", SWITCH_TO_NORMAL_CAMERA_TIME );
 }

 public function SwitchToNormalCamera()
 {
  cameraNormal.SetActive(true);
  cameraRed.SetActive(false);
  cameraBlue.SetActive(false);
  cameraOrange.SetActive(false);
 }


 function Awake()
 {
  if ( Instance != null )
  {
   Destroy (this );
  }
  else
  {
   Instance = this;
  }

 }

 function Start ()
 {
  SwitchToNormalCamera();
 }

}

No comments:

Post a Comment