Hi everyone,
I use a small script to toggle between two cameras when pressing a key wich is working fine while playing in editor but not when using the build.
This is the script I use, partially found on the forum here (thanks for that!):
var Main_Camera : GameObject;
var Main_Camera_In : GameObject;
var cSwap : boolean;
function Update ()
{
if (Input.GetKeyDown("c"))
{
cSwap = !cSwap;
}
if (cSwap)
{
Main_Camera.active = false;
Main_Camera_In.active = true;
}
else
{
Main_Camera.active = true;
Main_Camera_In.active = false;
}
}
Is there anything to put in or to change in preferences so that it will work also in a build?
Thanks!
anon_31460993:
Hi everyone,
I use a small script to toggle between two cameras when pressing a key wich is working fine while playing in editor but not when using the build.
This is the script I use, partially found on the forum here (thanks for that!):
var Main_Camera : GameObject;
var Main_Camera_In : GameObject;
var cSwap : boolean;
function Update ()
{
if (Input.GetKeyDown("c"))
{
cSwap = !cSwap;
}
if (cSwap)
{
Main_Camera.active = false;
Main_Camera_In.active = true;
}
else
{
Main_Camera.active = true;
Main_Camera_In.active = false;
}
}
Is there anything to put in or to change in preferences so that it will work also in a build?
Thanks!
I think you could do this one (I dunno if its working though):
function Update ()
{
if (Input.GetKeyDown("c"))
{
Main_Camera.active = !Main_Camera.active;
Main_Camera_In.active = !Main_Camera_In.active;
}
}
Hey nekroadmin,
your code works fine as well in the editor and is shrunked to a good minimum, thank you!
But as the version before, it also does not work when I build an executable.
I probably have to determine some things before building but can’t see it.
Ok, i think the problem is depth. try to change depths on both cameras. like… one camera has 0 and the other 1 or -1 and tell me how it went.
I did not change anything because from now to then it worked.
Very strange.
Nevertheless, thank you for your help!