Check out example codes for "unity variable from another script". It will help you in understanding the concepts better.
Code Example 1
//Make Health public
public class PlayerScript: MonoBehaviour {
public float Health = 100.0f;
}
//Access it.
public class Accessor : MonoBehaviour {
void Start()
{
GameObject thePlayer = GameObject.Find("ThePlayer");
PlayerScript playerScript = thePlayer.GetComponent<PlayerScript>();
playerScript.Health -= 10.0f;
}
}
Code Example 2
public class Script1 : MonoBehavior
{
public static int Script1Int;
}
//Another script:
public class Script2 : MonoBehavior
{
public static int Script2Int;
void Start()
{
Script2Int = Script1.Script1Int;
}
}
Learn ReactJs, React Native from akashmittal.com