From e43ecb338f704bc21a4004a07a902a04ece71d93 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sun, 28 Jan 2024 02:48:34 +0100 Subject: [PATCH] fix: camera issue when no camera --- Assets/Scripts/CameraManager.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/CameraManager.cs b/Assets/Scripts/CameraManager.cs index 32f4568..0504a68 100644 --- a/Assets/Scripts/CameraManager.cs +++ b/Assets/Scripts/CameraManager.cs @@ -31,11 +31,14 @@ void Start() // Update is called once per frame void Update() { - if (wTexture) + Texture2D texture = GetPhoto(); + + if (texture) { - photoBox.texture = GetPhoto(); - Resources.UnloadUnusedAssets(); + photoBox.texture = texture; } + + Resources.UnloadUnusedAssets(); } public void WebcamResume() @@ -123,7 +126,7 @@ public Texture2D GetPhoto() return photo; } - if (!wTexture) + if (!wTexture || WebCamTexture.devices.Count() < 1) { return null; }