Accessing new UI components in canvas.

I would like to know how to access specific UI component in the canvas.For example I have some game object with script which needs to set 2 text fields dynamically which located in the canvas .How do I get reference to each of these text objects in the script?

Very generally…

using UnityEngine.UI;

//Stuff

void SomeFunction() {
  InputField[] inputs = GameObject.Find("Name of Canvas").GetComponenetsInChildren<InputField>();
  inputs[0].text = "Text here";
}

This is rough and in general. There’s better specific ways to do it, but this will collect all InputFields in a given Canvas.