I need help accessing other scripts through script

So I have a glossary of names I’d like to name my guys with, ie bob, francis, etc. I don’t want to put the entire glossary onto each and every unit because that would most likely take up a lot of space just holding lists of names and other information on them all the time. So really simply I’d like to have an empty game object which holds all of this information as a single script. My problem is that I"m pretty new to Unity and I don’t really know how to do this process much at all. The problem is with getting the name from this gameobject and i’m not sure how to do it.

private int firstNameSelecter;
private int secondNameSelecter;

public string firstName;
public string secondName;

void Start() {

 firstNameSelecter = random.range(1,20);
 secondNameSelecter = random.range(1,20);
 firstName = ???????
 secondName = ????????


The gameObject in question is just called Dictionary with a script called Dictionary. Any help would be greatly appreciated. Thanks guys


If you want to access “firstName” variable from Dictionary script then you should write like this :

 var dictionaryObj = GameObject.find("Dictionary").GetComponent<Dictionary>();
 String name = dictionaryObj.firstName;

This way you can get value of firstName variable of another script.


Hope this will help u.