The variable has not been assigned

Unity is telling me that “spriteRenderer” under void DoTheThing(){ has not been assigned but I have it assigned. Am I missing something?

public Animator myAnim;
//private string[] myArray = {"PhaseThru", "ExtraWarning"};
public SpriteRenderer spriteRenderer;

public virtual void start()
			if (GetComponent<SpriteRenderer> ()) {
					// save the current sprite as the up sprite
					spriteRenderer = GetComponent<SpriteRenderer> () as SpriteRenderer;
public void DoTheThing () {

    spriteRenderer.enabled = true;
    myAnim.SetBool("Warning", true);
    Debug.Log("Doing the thing!");

// Update is called once per frame
void Update () {



You need to capitalize Start. The method named ‘start’ will never be run.

As long as you have a Spriterenderer attached to the same object, this code:

void Start() {
    spriteRenderer =  GetComponent<SpriteRenderer>();

will work. Note that with the generic version (), you won’t need the cast (“as SpriteRenderer”)