Skip to content

Instantly share code, notes, and snippets.

@psema4
Created September 8, 2016 05:05
Show Gist options
  • Save psema4/6fa53386e6a0452ac1e0438fa677efe6 to your computer and use it in GitHub Desktop.
Save psema4/6fa53386e6a0452ac1e0438fa677efe6 to your computer and use it in GitHub Desktop.
Useful strategy to manage "unlimited" cameras in Unity 3D
// Source: Archimagus on "Most efficient way to incorporate CCTV screens in Unity?"
// https://www.reddit.com/r/Unity3D/comments/2z7u4c/most_efficient_way_to_incorporate_cctv_screens_in/cpgql85
Camera[] _securityCameras;
void Start()
{
foreach(var s in _securityCameras)
{
s.enabled = false;
}
StartCoroutine(UpdateCameras());
}
IEnumerator UpdateCameras()
{
while (true)
{
for (int i = 0; i < _securityCameras.Length; i++)
{
_securityCameras[i].Render();
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment