Hi,
i want to make Key-Cards in my game and have different codes on them, so i made a code, the code generates a random text and should put it on a text mesh, here is the code:
function Start()
{
var text = “”;
var length = 10;
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0;i < length; i++)
text += possible.charAt(Mathf.floor(Mathf.random() * possible.length));
GetComponent(TextMesh).text = text;
}
it seems like it doesn’t work, help please.
THX lixpoxx
Try this:
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var length = 10;
function Start() {
var text = "";
for( var i=0;i < length; i++)
text += possible[Random.Range(0, possible.Length)];
GetComponent(TextMesh).text = text;
}