Adjust variable in inactive script

Can you change a variable of a script that is not in the scene or hierarchy, from another script? I can do this easily when the two scripts are in the scene or hierarchy, but how can I change a variable of a script that is just in my assets? If it is not possible I have a workaround ready, but I am very curious if this is possible?

Thank you!

One way would be by first making the var static, then changing it using an internal static function. For example :

public static int myVariable;

internal static void ChangeMyVariable(int newValue)
{
   myVariable = newValue;
}

You could access the variable by :

yourInt = ClassName.myVariable;

Or change it by:

ClassName.ChangeMyVariable(100);

Hey thanks for the quick response. Is this possible with UnityScript?

I haven’t tried, but most probably.

Alright I’ll try and figure something out, thanks for your feedback I appreciate it.