void OnDestroy() { loaded = false; if (videoStream != null) { videoStream.FrameChanged -= FrameChanged; videoStream.Dispose(); videoStream = null; } if (outputTexture) { Destroy(outputTexture); } Unregister(); }