getcomponent cant find every button script in every gameobject

so yesterday my code is working, but now its error.
i found the problem is the unity cant find button object, i dont know why so i erase all code and make something simple like in image

but then program still print null, and the object is founded. what is wrong with my code,the name is already correct.

Try to change to Text,unity can find it, but every button is always null.
what is wrong with this situation, and can i get the solution thank you :slight_smile:
(sorry if my english is bad)

Try this:

  1. Call GameObject btnGameObject = GameObject.Find("/Canvas/Pause_Button"); and inspect btnGameObject so it should be not null. It checks the GameObject with this name is in the hierarchy. Notice “/” at the beginning of the string ID "/Canvas/Pause_Button" so to perform the search from the Root.

  2. When btnGameObject is not null, perform Button btn = btnGameObject.GetComponent<Button>() and inspect btn is not null. It checks the “Button” component is attached to the “/Canvas/Pause_Button” GameObject.

Your code looks good so I think the problem is in the ID or missed component.