Last active
December 16, 2015 16:49
-
-
Save s2kw/5465729 to your computer and use it in GitHub Desktop.
Sample for Looking for Overhead at Instruments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class MaterialChanger : MonoBehaviour { | |
Material mat; | |
// Use this for initialization | |
IEnumerator Start () { | |
while(true){ | |
StartCoroutine("ChangeColor"); | |
yield return new WaitForSeconds(5f); | |
StopCoroutine("ChangeColor"); | |
yield return new WaitForSeconds(2f); | |
InstantiateMe(); | |
} | |
} | |
// Update is called once per frame | |
IEnumerator ChangeColor () { | |
Debug.Log("Changer run"); | |
int x = 100; | |
for(int i = 0; i < x; ++i ){ | |
x = UnityEngine.Random.Range(1, 1000); | |
switch( x % 5 ){ | |
case 0: | |
renderer.material.color = Color.red; | |
break; | |
case 1: | |
renderer.material.color = Color.blue; | |
break; | |
case 2: | |
renderer.material.color = Color.green; | |
break; | |
case 3: | |
renderer.material.color = Color.black; | |
break; | |
default : | |
renderer.material.color = Color.white; | |
break; | |
} | |
yield return null; | |
} | |
} | |
void InstantiateMe () { | |
Debug.Log("InstantiateMe run"); | |
int x = 5; | |
for(int i = 0; i < x; ++i ){ | |
GameObject go = gameObject; | |
Instantiate(go,transform.position,transform.rotation); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment