Cameras not switching with a UI Button
I am trying to have a UI Button that when pressed, will switch to another camera. There is no need for it to switch more than once. Here is the code that i currently have:
public class StartSwitch : MonoBehaviour
{
public Button.ButtonClickedEvent onClick;
public Button m_Button;
public Camera m_MainCamera;
public Camera m_CameraTwo;
void Start()
{
m_Button.onClick.AddListener(Switch);
m_MainCamera.enabled = true;
m_CameraTwo.enabled = false;
}
void Switch()
{
m_CameraTwo.enabled = true;
m_MainCamera.enabled = false;
}
}
When i now go to play and click the button, it turns off the cameras. It says "Display 1, No Cameras Rendering" So it doesn't activate the other camera it just disables the one that is currently active. I have been trying to find a fix, but haven't found one. If someone could help me out, that would be appreciated Thanks! :)
Comment