Button only works once

I’ve made a function that makes to read a “document”, getting the child objects from where the button is, and putting those texts to show. But when I click the document it shows well, but only ONCE!

For example, if I have 2 documents in my inventory, I only can read the first one I click, and when I click another document, it still shows the info about the first one I clicked.

Here’s my code that reads documents:

public void ReadClickedDocument()

        Component[] components;
        components = GetComponentsInChildren<Text>();

        //The child #0 of the prefab will contain the title of the document, the next one the body.. etc.
        _documentTitle.text = components[1].GetComponent<Text>().text.ToString();
        _documentBody.text = components[2].GetComponent<Text>().text.ToString();


And this is the code that adds the function to the instantiated button:

newbuttonToInst.GetComponent<Button>().onClick.AddListener(() => { ReadClickedDocument(); }); //Set the function to read the document

I may try to implement ReadClickedDocument() to a new script binding to button object.
And override OnClick() to call this function as well. To achieve your goal.

I didn’t use AddListener() before though.

Hope that helps.