Noob Question about classes and methods

I’ve seen some training videos and I thought I’ve had it figured out. guess now.
I’m trying something simple. I’ve got a UI button that printed a text just for testing, that worked.
next I’m trying to create a class (or method?) in a different script that the button calls to

so the class goes like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Builder : MonoBehaviour
{
public void Build()
{
Debug.Log(“Builder: building complete.”);
}
}

this seems ok as in it doesn’t give any errors.
the button script is giving me issues and I guess I haven’t figured something out:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonTest : MonoBehaviour
{
public class Builder()
{
print(“inside ‘builder’”);
}

}

I’ve tried various combination of getting/calling the other script but I’m just getting frustrated.
Guess I haven’t figured some stupid annoying typo thing…

Why are you using the Print method in the button script? You can use the Debug.Log() like in the other script you have.

Objects can contain related data. Classes are specific types of Objects, such as “Character” or whatever you come up with. A class can contain attributes (such as Name, HP, ATTK, …), the values of which make up the state of a specific instance of this type. Classes can also contain methods. Methods can contain executable code (which may or may not alter the state of the instanced object). In your second example you directly wrote executable code in your class, which should not even compile.
If you require further explanations on some topic or an example, feel free to ask.

If I delete the class in the second scripot and I’m left with only
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Builder();
or
Build();

I’m getting errors about namespaces

First of all, for the future please use code tags. That way people can actually have a look at your examples with some syntax highlighting, and it’s also easier to spot as code in the first place. Example below; it’s the <> button above the textfield when you post something here.
Secondly, when you mention some error, as a rule of thumb people will always ask for the error message, so directly adding it when mentioning an error is a good idea.

I’m also not entire sure what it is you are trying to achieve. Your first example, where you called the Build() method from some script was already pretty much what you are supposed to do. You have to give your button some method from some script, which it will execute onClick. If you want to access data from another class, then you have to access that data inside the function called by the button. Example:

public class ButtonTest: MonoBehaviour
{
    Character exampleInstance;

    void Start(){
        // We create some instance of Character and save it into the above field
        exampleInstance = new Character("John Doe");
    }
 
    public void ButtonOnClickMethod(){
        // We can access the data from some other class (instance) here
        Debug.Log(exampleInstance.name); // <-- prints "John Doe", which is data from some other class instance
    }

}

public class Character{
    public string name;

    // Possibly some other attributes we dont use in this example
    private int attk;

    // Constructor, constructs an instance of this class
    public Character(string name){
        this.name = name; // assign the parameter name to this instance
    }
}

Hope this helps clearing some misunderstandings you may or may not have.

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().