How to have a variable accessible by all script

I am trying to make a logic, which requires one variable value to be accessible by more then one script. So I have 2 questions:

Q1: How to make variable such that it is accessible by all scripts?

Q2: When I change from Scene 1 to Scene 2, and then come back to Scene 1 from Scene 2, I want the variables to be initialized again to default value.
like for example:

Script 1 has a Bool variable with false as initial value
var Button1 = false
after some logic value changes to true, and now we move to scene 2

In scene 2, after some logic we come back to Scene 1,
the value of Button1 is still true. I want Button1 value to be false value which is being assigned when initialized.

if you wanted to set the value of your button1 as initialized, then reload the scene1 when you switch to scene1, and all the variables of the script will be reset.

1 Like