How often should I "GetComponent" ?

I create base canvas. It’s have template for information. After I click “Info” button. It’s “GetComponent” to change text in canvas.

I am not sure it’s have performance.

One/few clicks wont matter, would be problem if you call it constantly inside a loop or so.

You can still cache the result if you want,

if (clicked..)
{
if (txtReference==null) txtReference=GetComponent<Text>(); // cache it if not yet
  txtReference.text = "Nice!";
..
}

Thanks You! I want to ask you. In mobile games. I wonders it’s have many scenes or many canvas ??? Example Shop UI.

It should be pretty much the same. Unless you’re running out of memory, you should keep things like the shop loaded and deactivated, so the player doesn’t have to wait for them to get instantiated.

For canvases, there’s some clever things here about optimization.