Reference missing in runtime

I lose a reference of a gameObject when I start a game. I’ve tried GetComponent<>(), GameObject.Find() and Resources.Load(), but nothing works.138516-capture3.jpg

Hello there,

I would start by changing a few things in your scripts. For your purpose, it would probably end up more like this:

public GameObject light = null;

private void Start()
                Debug.LogWarning("GameObject light is not assigned!");
                light = gameObject;

Please note that for GameObjects you shouldn’t be using GetComponent<>(). the gameObject property will already return the GameObject your script is attached to.

Hope that helps!