Creating Buttons with a C# Script

I’m trying to look at an array of text and use that to determine how many buttons I need and what the text on the buttons say, but, so far, I can’t even create the buttons. They also need to be aligned on a Horizontal Layout.

void    UpdateDialogue()
    {
                if (characterName.Equals("Questions"))
                {
                    CreateNewQuestionObject();
                }    
    
    }
    
    
    void CreateNewQuestionObject()
        {
            question = (GameObject)Instantiate(Resources.Load("QuestionTemplate"));
            question.transform.SetParent(questionPanel.transform);
        }

Check the manual : Redirect to... title of new-page

// Drag & Drop the prefab of your button
public GameObject QuestionTemplate;

// Drag & Drop the gameobject with the Horizontal layout
public RectTransform questionsPanel ;

 void UpdateDialogue()
 {
      if (characterName.Equals("Questions"))
      {
           CreateNewQuestionObject();
      }
 }     
 
 void CreateNewQuestionObject()
 {
     RectTransform questionTransform = ((GameObject)Instantiate( QuestionTemplate )).GetComponent<RectTransform>();
     questionTransform.SetParent(questionsPanel );
 }