I have an element that I am trying to change its appearance using a spriterenderer, and while my sprite changer script successfully changes the sprite renderer in the inspector, there's no visual change in the scene. It works, the spriterender changes, but nothing actually looks different on scene. It's not giving any error messages, I've included a picture of the inspector in case I'm doing something wrong there. [inspector](https://i.stack.imgur.com/vNxuK.png)
This is my code for the sprite changer, fairly simple:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpriteChanger : MonoBehaviour {
public Sprite[] sprites;
SpriteRenderer SpriteRend;
void Start() {
SpriteRend = gameObject.GetComponent<SpriteRenderer>();
}
public void ChangeSprite(int i)
{
SpriteRend.sprite = sprites[i];
}
// Start is called before the first frame update }`
I checked your code and it works perfectly, the only thing I edited is the Start method to actually call the
ChangeSprite(). Double check what object you're looking at and if maybe your camera is at 90 degree angle to the SpriteRenderer because you'll not see it from the side. Also check theOrder in Layerparameter at SpriteRenderer component since it could happen that something else in the same layer is rendering on top. Also check the eye button in front of your sprite object (or its parent) in Hierarchy tab (you might just hide the object from Scene View) and check the object's layer and Camera's rendering layer mask so that they two intersects.