I’m trying to create a script to randomly change the texture for a group of sprites. I’ve tried
newCell.GetComponent(SpriteRenderer)
but that doesn’t allow access to the sprite, I’ve also tried adding a script to the object whose sprite I’m trying to change using code I’ve found in other answers
var spriteImage : Sprite;
function Start () {
GetComponent(SpriteRenderer).sprite = spriteImage;
}
But that is javascript and C# can’t seem to find javascript scripts with GetComponent, so I can’t access it that way either. Changing it to C# should look something like this
Sprite spriteImage;
void Start () {
spriteImage = GetComponent(SpriteRenderer).sprite;
}
But it once again can’t access .sprite.