# Need help with a Graphic

I need to creat a Graphic with a random array

var intArray : int[ ] = new int[10];
var convertedArray : Array = new Array(intArray);
var a: int=0;

for (var i = 0; i < convertedArray.length; i++)
{
a= Random.value*10;

Debug.Log(“ConvertedArray[” +i + "]: " + a);
}
}

I have this random array, i thinked to use the function DrawLines but it did not work… the graphic needs to show the times that the numbers (0-9) appers.

Other thing that I thinked was use 10 cubes and transform the scale in Y. Each cube represents each number.

Can you guys help me?

Using cubes to create a graph to show how often you got each number is a good approach. It’s easiest to store how often you got each value, instead of storing the values themselves, like so

var intArray: int[ ] = new int[10];
for(var i = 0; i < numberOfSamples; i++){
intArray[Random.Range(0, 10)] += 1;
}[/code]

HUM… yeah I think that it will be the best thing… but i don’t know how i can do it > . <"
Can you explain to me?

I really need it guys, please.

This script will generate a crude bar graph once. Throw it on something, like the Main Camera, and assign it a standard cube prefab and how many numbers you want to pick.

``````var prefab: Transform;
var numberOfSamples: int;

function Start () {
var valueCount: int[] = new int[10];
for(var i = 0; i < numberOfSamples; i++){
valueCount[Random.Range(0, 10)] += 1;
}
for(i = 0; i < valueCount.length; i++){
var bar: Transform = Instantiate(prefab);
bar.localScale.y = valueCount[i];
bar.localPosition.y = valueCount[i] / 2f;
bar.localPosition.x = i * 1.1f;
}
}
``````