- Home /
This question was
closed Jul 11, 2014 at 05:56 AM by
Loius for the following reason:
Duplicate Question
Question by
markzareal · Jul 11, 2014 at 05:54 AM ·
javascripterror
BCE0005: Unknown identifier: 'spriteRenderer'.
#pragma strict
var diamond : Texture;
var square : Texture;
var triangle : Texture;
var circle : Texture;
var start : Texture;
private var number : int = Random.Range(1,4);
function Start () {
spriteRenderer.Sprite = start;
}
function Update () {
if (number == 1) {
spriteRenderer.Sprite = diamond;
}
else if (number == 2) {
spriteRenderer.Sprite = square;
}
else if (number == 3) {
spriteRenderer.Sprite = triangle;
}
else {
spriteRenderer.Sprite = circle;
}
}
I don't get what I got wrong here. It said BCE0005: Unknown identifier: 'spriteRenderer'. Anyone help please? Thanks
Comment
Best Answer
Answer by Loius · Jul 11, 2014 at 05:56 AM
GameObject does not have a spriteRenderer member. It does have a renderer member. You have to get the spriterenderer yourself using GetComponent. '.Sprite' should be '.sprite'.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Exception error 1 Answer
JS Unity Boolean 'not possible to evoke an expression of type 'boolean'' 1 Answer
BCE0049 error with network script 0 Answers