My Problem:
I have a component in my script, and I set it using: GameObject.FindGameObjectByTag("MyTag").GetComponent<MyComponent>();
But in my game the gameObject I’m getting this component from gets destroyed, and re-instantiated regularly.
And when I set the components in my script again with GameObject.FindGameObjectByTag("MyTag")GetComponent<MyComponent>();
they still use the old reference, I checked this using: Debug.Log(componentVar.gameObject.name); ← because the instantiated gameObject has a different name than the old one.
I have already tried to set the componentVar to null before setting it again, but it still used the old reference.
In short:
I need a way to confirm my componentVar is using the new reference instead of the old one.