Is it possible to change a variable, into a script not assigned to any game object?

Hey guys,
One exemple, i have two scripts, script A is assigned to a empty into my scene, and script B is one script to help many things into the application, but it’s not assigned to any game object in any scene, and it has a int variable, and a want modify the value of this variable from my A script, is it possible?

If you use a public static variable it can be accessed from anywhere. I believe it still holds true if it is not attached to an object. For example, I can access this float var from any script without it being attached to the same object.

public static var myFloat:float;

If script B is deciding many things for the game, then it should be something like a Game Controller, which usually is assigned to a empty Game Object in the scene.
For example, you create an Empty Game Object and name it as Game Controller and then assign the script to it.

If you don’t want to assign the script to any object, then you can make your variables static, so that it should be available like YourScript.staticVariableName and you can use or assign values to it. Like if( YourScript.staticVariableName == anotherValue) or YourScript.staticVariableName = anotherValue;

using UnityEngine;
using System.Collections;

public class GuiMainMenu : MonoBehaviour {

	private string keySound = "AUDIOGAME";
	public AudioSource click;
	public  GeneralGameSound  x;
void Start () 
	     x = GetComponent("GeneralGameSound") as GeneralGameSound;

x.teste +=1;

void Update(){

This was the A script, and this

using UnityEngine;
using System.Collections;

public class GeneralGameSound : MonoBehaviour {

	public int test = 10;
	private static string x = "GONE";
	public static void setTeste(int at)
	public static int getTeste()
		return PlayerPrefs.GetInt(x,0);

is the B Script, what am i doing wrong?