C# referncing bool from one file into another?

What I have is 2 scripts. 1st contains a bool = true 2nd one needs to read and possibly change this bool but I got no idea how to access it. Thanks

If it is an instance field, then use `GetComponent()` and the variable name.

MyScript myScriptInstance = GetComponent<MyScript>();
Bool myBool = myScriptInstance.myBoolean;
//These could be nested together, you would still allocate memory it just might look a little cleaner.

If it is a class variable, you can access it just like any other class var.

Check this out:


just change from javascript to C#.

Good luck.