Creating my own DrawButton method but am stuck

In my game instead of using if (GUI.Button(new Rect(10, 70, 50, 30), “Click”)) {} to draw my buttons I want to have a method which does that for me; in my game I set the size of the text, make a custom texture etc. However I’ve been running into a few problems. I’ve gotten the top code to draw my button but am having issues making code run when button is pressed - bottom code.

GetComponent<DrawMethods>().DrawButton(...);

if (GetComponent<DrawMethods>().DrawButton(...))
{
    NextTurn();
}

I thought maybe since Gui.Button used the if statement like that to capture a user pressing the button I could do the same with my method, but I was mistaken. So my question is, is there a way I can alter that to make it work? Or if not, can anyone tell me how I can convert strings to be usable code? I noticed that if I have the if (Gui.Button…) code in the DrawButton method I can make the button be usable upon calling method, however I want to be able to send my code into that if statement. I’m trying to make a script which can be usable across different projects.

And also, I’ve spent multiple days Googling for ways to solve my problem but that’s gotten me nowhere. The code people put up, or answers, to convert strings into code either didn’t make sense in my situation or just didn’t work when I put it into my game and altered it. And the if (GetComponent().DrawButton(…)) {NextTurn();} solution is hard to know what to Google and get the answer you want.

I’m going to guess that you’re missing the return. But without seeing the code, I have no idea what the problem is.

public bool DrawButton(Rect rect, string text)
{
	return GUI.Button(rect, text);
}

void OnGUI () 
{
	if (DrawButton( new Rect(100f, 100f, 100f, 100f), "test button"))
	{
		Debug.Log("button clicked");
	}
}