- Home /
Question by
prajwalg8736 · Dec 29, 2020 at 06:51 AM ·
camerawebglpausepause game
How to pause a frame in unity , that works even in webgl ?
As i tried to use second camera to pause the frame(by rendering only UI elements before new game objects were loaded into the scene and then enable main camera to render everything) , which worked as intended in unity but there was a glitch in webgl before the first camera starts rendering .
IEnumerator FreezeCam()
{
//saving previous culling mask and clearing flags
Previous_mask = Camera.main.cullingMask;
Previous_clear_flags = Camera.main.clearFlags;
Camera.main.clearFlags = CameraClearFlags.Nothing;
Camera.main.cullingMask = 0;
yield return null;
}
IEnumerator Play_cam()
{
//assigning previous culling mask and clearing flags
Camera.main.clearFlags =Previous_clear_flags;
Camera.main.cullingMask = Previous_mask;
yield return null;
}
public void secondary_camera_setting()
{
//Camera.main.enabled = false;
if (secondary_Cam != null)//enabling secondary camera not to render anything
{
//to render only UI using culling mask
secondary_Cam.enabled = true;
secondary_Cam.cullingMask = 1 << LayerMask.NameToLayer("UI");
}
}
IEnumerator LoadGameObjects()
{
..................
..................;
StartCoroutine(Play_cam());
}
void Start()
{
StartCoroutine(FreezeCam());
secondary_camera_setting();
UnityMainThreadDispatcher.Instance().Enqueue(LoadGameObjects());
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613022326im_/https://answers.unity.com/themes/thub/images/avi.jpg)