I’m getting error messages when trying to change a SpriteRenderer’s sprite at runtime.
The error doesn’t seem to make any sense.
Here’s the line that is producing the error:
myRenderer.sprite = Skirt_UDLR;
myRenderer is a variable of type SpriteRenderer that is properly assigned in Start().
myRenderer = GetComponent<SpriteRenderer>();
Skirt_UDLR is a public variable of type Sprite in my code that has been properly assigned with a Sprite in the inspector.
So, in theory, there’s no reason the code shouldn’t work, yet I’m getting this error in debug:
NullReferenceException
UnityEngine.SpriteRenderer.set_sprite (UnityEngine.Sprite value) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/SpritesBindings.cs:176)
But this error has nothing to do with my code, I don’t think, as it’s an error with a base Unity script. Anyone know what’s going on here?