Just game object don't containt something variables. All possible variables contain in components, what a object have.
Accessing a variable on MonoBehaviour is normally a three step process:
- Get a reference to the appropriate GameObject.
- Get a reference to the appropriate Component with "GetComponent" method.
- Access a public member with a operator point.
Step one can often be skipped if you drag and drop references in the inspector, use a singleton, pass in a component reference, or any number of other approaches.
GameObject.GetComponent<ClassName>().VariableName = 5;