Multiple world space event cameras
Hi I have a script that swaps out my cameras. Then i have a button in world space.
The issue is that the world space canvas script only allows one event camera to be plugged in, so i can only get one of the 2 cameras to interact with the world space button. How can I make both work?
Thanks
Comment
I would say that the best bet is have some form of public get property on your camera-swapping script, that returns the currently active camera, then set that for the world space canvas you need to use.
Answer by DroidifyDevs · May 04, 2016 at 04:10 PM
I'd say just create all the cameras you want and disable them. Then in your script with the button you can simply have the button enable one at a time. Like this:
public GameObject Camera1;
public GameObject Camera2;
void Start()
{
Camera1.gameobject.SetActive(false);
Camera2.gameobject.SetActive(false);
}
public void Button()
{
if (Camera1.gameObject.SetActive(false))
{
Camera1.gameobject.SetActive(false);
Camera2.gameobject.SetActive(true);
}
if (Camera2.gameObject.SetActive(false))
{
Camera1.gameobject.SetActive(true);
Camera2.gameobject.SetActive(false);
}
}
}