2016年12月15日 星期四

12/16 紅綠燈


using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {

// Use this for initialization
void Start () {
}
int c = 0;
// Update is called once per frame
void Update () {

c =c+1;

Image img1 = GameObject.Find ("Image").GetComponent<Image> ();
Image img2 = GameObject.Find ("Image1").GetComponent<Image> ();
Image img3 = GameObject.Find ("Image2").GetComponent<Image> ();

if (c % 15 >= 0 && c%15<=4)
{
img1.color = new Color(1.0F, 0.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
img2.color = new Color(0.0F, 0.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
img3.color = new Color(0.0F, 0.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
}
if (c % 15 >= 5 && c%15<=9)
{
img1.color = new Color(0.0F, 0.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
img2.color = new Color(1.0F, 1.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
img3.color = new Color(0.0F, 0.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
}
if (c % 15 >= 10 && c%15<=14)
{
img1.color = new Color(0.0F, 0.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
img2.color = new Color(0.0F, 0.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
img3.color = new Color(0.0F, 1.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
}

}
}

沒有留言:

張貼留言