private void OnDestroy()
{
//STEP9: GameObject is being destroyed either due to user action, another script or
//because Unity shuts down -> end the calls + cleanup memory
//This step is extremely important and not cleaning up might
//cause stalls or crashes. It will also keep the users webcam active thus
//preventing other apps from accessing it
if (receiver != null)
{
receiver.Dispose();
receiver = null;
}
if (sender != null)
{
sender.Dispose();
sender = null;
}
}
}