Can't change the Unity UI dispaly from script


So I am working on my final project and I need to change display when I clicked the button on the screen. But when I clicked it, it only displays “Display 1 No Cameras Rendering”. Actually I need to change main cameras display with other cameras but it’s not working. Code and screenshot of UI is down below so I hope you can help me about it. Thanks.


void Start()

void changeCamera()

        tempDisp = mainCam.targetDisplay;
        mainCam.targetDisplay = panoramicCam.targetDisplay;
        panoramicCam.targetDisplay = tempDisp;
        button.GetComponent<Text>().text = "Ana Kamera";
        text.text = "Kuşbakışı Kamera";

        tempDisp = panoramicCam.targetDisplay;
        panoramicCam.targetDisplay = mainCam.targetDisplay;
        mainCam.targetDisplay = tempDisp;
        button.GetComponent<Text>().text = "Kuşbakışı Kamera";
        text.text = "Ana Kamera";


Correction: When I try to change their activity in if statements problem is still same.