Hiding buttons (GUI.Button)

Hello friends, someone who can help me ?? I’m working with augmented reality in unity and have 2 buttons (GUI.Button) which you want me to appear only when the camera detects the marker, and the buttons are hidden if the camera does not find the marker. Any suggestions?

Try:

private bool cameraDetectsMarker = false;

void Update() {
    cameraDetectsMarker = //(your code to check if camera detects marker)
}

void OnGUI() {
    if (cameraDetectsMarker) {
        if (GUI.Button(rect1, "button 1")) {
            //(code when button 1 is clicked)
        }
        if (GUI.Button(rect2, "button 2")) {
            //(code when button 2 is clicked)
        }
    }
}

Detect the marker in a separate routine, like Update(), not in OnGUI(). This is because OnGUI() is called several times per frame and shouldn’t do anything except GUI drawing and input.