Noob Question about classes and methods

Please use code tags .

Most of the time, if you want to access a method or variable on another class, first you need a variable containing a reference to the specific object you want to talk to. This might look something like:

public class ButtonTest : MonoBehaviour
{
    public Builder myBuilderVariable;

    public void SomeFunction()
    {
        myBuilderVariable.Build();
    }
}

By default, this variable will be “null”, which you can’t use for anything. So before you run SomeFunction(), you’ll need to assign a value to it. (One easy way to do that is by dragging a reference to it in the Unity inspector for your object.)

The reason you need this variable is because there could be more than one Builder in your game, so the computer needs to know which of them is supposed to Build().