- Home /
Color Array in C#
Hi guys, I have this code:
using UnityEngine;
using System.Collections;
public class ScriptEnemy: MonoBehaviour {
public int numberOfClicks = 2;
public float fWaitTime = 2;
public color[] shapeColor;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 varPosition;
if (numberOfClicks <= 0 ){
varPosition = new Vector3(Random.Range(-6,6),Random.Range(-4,4),0);
RespawnWaitTime();
transform.position = varPosition;
numberOfClicks = 2;
}
}
IEnumerator RespawnWaitTime() {
transform.renderer.enabled = false;
ChangeColor();
yield return new WaitForSeconds(fWaitTime);
transform.renderer.enabled = true;
}
void ChangeColor() {
if (shapeColor.length > 0){
int newColor = Random.Range(0,shapeColor.length);
renderer.material.color = shapeColor[newColor];
}
}
}
And Im getting this error
Assets/Scripts/ScriptEnemy.cs(7,16): error CS0246: The type or namespace name `color' could not be found. Are you missing a using directive or an assembly reference?
I want to set an array of colors visible on the inspector. Can someone help me?. The array length can be X, I don't know how many colors are going to be drawn.
Comment
Best Answer
Answer by Eric5h5 · Apr 08, 2012 at 05:54 PM
"Color[]", not "color[]". All classes and structs are uppercase; it's only primitive types (float, int, etc.) that are lowercase.