I've been making a simple brick-breaker game using unity 4.3 (In C#). I'm currently trying to make the blocks, which are stored in an array, all start with random colour properties. The colours are working correctly, but I want the blocks to start invisible, and then be assigned the various colours. I have researched, and found similar questions on changing the mesh-renderer component, but, as yet, they haven't worked. Here is my code:
EDIT: To put it simply: how do you make objects invisible, test if they are invisble or not and make them visble again.
using UnityEngine;
using System.Collections;
public class BlockInitialiser : MonoBehaviour {
GameObject[] blocks;
// Use this for initialization
void Start ()
{
blocks = GameObject.FindGameObjectsWithTag ("Brick");
StartCoroutine (blockColour ());
}
IEnumerator blockColour()
{
foreach (GameObject block in blocks)
{
block.renderer.material.color = new Color (Random.value, Random.value, Random.value);
yield return new WaitForSeconds (0.1F);
}
}
Thanks in advance, guys.