Hi:
I would like to add a script to a var as below. then be able to assess it. Is this possible?
First Script:
public class FirstScript: MonoBehaviour
{
private MonoBehaviour script; //works
void Awake()
{
script = gameobject.Getcomponent<SecondScript>(); //works
}
void ThisMethod()
{
script.someVar = 99; //here is my problem!
script.Use(); //here is my problem!
}
}
Second Script:
public class SecondScript: MonoBehaviour
{
public int someVar;
public void Use()
{
print("used");
}
}
I cant seem to access the script variables and methods this way and would like to due to being able to change scripts. All the scripts will have “someVar” and “ThisMethod”. or am I trying something that is not possible?