I Think I Found A Bug

I had created a GameObject to access all scripts and I was accessing all scripts through the script inside this object. Like;

AccessScripts.playerController.someVariable = "test value";

Everything was ok. But today, when I tried to change the gameOver value in PlayerController, I saw that the inside of my PlayerController script did not change. But when I did AccessScripts.playerController.gameOver (in my another script), I could see that the value there had changed. I solved this problem by accessing directly from within the current script I am using instead of AccessScripts. But I think this is a bug and it needs to be resolved.

My AccessScripts;

[HideInInspector] public static PlayerController playerController;

playerController = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();

Edit:
This is my mistake. Thanks :smile:

You’re not really giving enough info and honestly, it’s not likely a bug in Unity if that is what you’re thinking.
You’re saying you see the “inside of the script doesn’t change”… I’m not sure what you mean.

Otherwise, the only things I can think of is an Order of Operations error or you’ve got multiple copies of a script/object in your scene. But, not really anything I can say to help cause I just don’t have enough info.

3 Likes

Not enough info. Could be caused by multiple instances of PlayerController in the scene, code not running which you are assuming is being run, or a variety of other causes.