How do you access a list from another script?
I can’t seem to get it to work.
My code looks something like:
//Script
public listScript script;
void Update()
{
print(script.list[0]);
}
How do you access a list from another script?
I can’t seem to get it to work.
My code looks something like:
//Script
public listScript script;
void Update()
{
print(script.list[0]);
}
Did you set the list as a static variable?
In the other script (the class you want to get the script from) the script variable has to be public static listScript script
public List iList = new List();
then from another script, you find your script using
GetComponent<SCRIPTNAME>().iList[0]