unity how to change the text of a ui element with code code example

Example 1: unity change text

// To change text of a text UI element use th combination below
textGameObject.GetComponent<UnityEngine.UI.Text>().text = "text";

Example 2: unity how to change the text on a button

GameObject.Find("Button Name").GetComponentInChildren<Text>().text = "Button Text";

Example 3: how to change the size of ui in script unity

_image.rectTransform.sizeDelta = new Vector2(width, height);

Example 4: unity change the source image or image

public Image test;
public Sprite example;

void Start()
{
 test.sprite = example; //change the source image of the image "test" to the sprite "example" 
}