Skip to content

Instantly share code, notes, and snippets.

@s2kw
Last active December 16, 2015 16:49
Show Gist options
  • Save s2kw/5465729 to your computer and use it in GitHub Desktop.
Save s2kw/5465729 to your computer and use it in GitHub Desktop.
Sample for Looking for Overhead at Instruments.
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