Hello guys!
I’ve got a ParentObject with a script called MainScript, and in the script, a method called printToConsole(). I want to access the printToConsole method from a script in the child object.
In the child object script, I’m writing the following:
MainScript ParentScript;
private void HandleSelected()
{
ParentScript = transform.parent.GetComponent();
ParentScript.printToConsole();
}
This gives me the following error:
error CS0246: The type or namespace name ‘MainScript’ could not be found (are you missing a using directive or an assembly reference?)
I’m new to Unity Development and would really appreciate some help. This seems to be an easy fix, but it just hasn’t worked for me and I’ve tried really hard for days to make this work.