本件と関係あるかちょっと分からないですけど、こちらの記事ではstart()直後は初期化が終わってなくて正しい解像度が取れないとかなんとか書いてありますね。
Like!
RICOH THETA V ライブ映像 を Unity で 映したいが
WebCamTexture could not find a supported resolution for the selected webcam.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
web:StartStreaming () (at Assets/web.cs:41)
web:Start () (at Assets/web.cs:12)
というエラーが出て反映されない
デフォルトの3dシーンにplane を追加 planeにweb.cs を追加
コード
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class web : MonoBehaviour
{
public string deviceNameKeyword = "RICOH THETA V";
private WebCamTexture webcamTexture;
void Start()
{
StartStreaming();
}
void StartStreaming()
{
WebCamDevice device = new WebCamDevice();
if (!FindDevice(ref device))
{
Debug.LogError($"キーワード: {deviceNameKeyword} を含むウェブカメラが見つかりませんでした");
return;
}
if (webcamTexture != null)
{
webcamTexture.Stop();
Destroy(webcamTexture);
}
webcamTexture = new WebCamTexture(device.name);
Material mat = GetTargetMaterial();
if (mat == null)
{
return;
}
mat.mainTexture = webcamTexture;
webcamTexture.Play();
Debug.Log($"デバイスからストリーミング中: {device.name}");
}
bool FindDevice(ref WebCamDevice target)
{
bool i = false;
WebCamDevice[] devices = WebCamTexture.devices;
Debug.Log(devices);
foreach (WebCamDevice device in devices)
{
Debug.Log($"利用可能なデバイス: {device.name},{device.availableResolutions},33333");
if (device.name.Contains(deviceNameKeyword))
{
target = device;
i=true;
}
}
return i;
}
Material GetTargetMaterial()
{
Skybox skybox = GetComponent<Skybox>();
if (skybox != null)
{
Debug.Log("ssssssssss");
return skybox.material;
}
Renderer renderer = GetComponent<Renderer>();
if (renderer != null)
{
Debug.Log("sss333333333");
return renderer.material;
}
Debug.LogError("Renderer または Skybox コンポーネントがありません");
return null;
}
}
本件と関係あるかちょっと分からないですけど、こちらの記事ではstart()直後は初期化が終わってなくて正しい解像度が取れないとかなんとか書いてありますね。
WebCamTexture could not find a supported resolution for the selected webcam.
WebCamTexture
は使ったことはありませんが、コンストラクタで解像度を指定できる(マニュアル)ようですから、WebCamDevice.availableResolutions
のいずれかをコンストラクタで指定してみたらいかがですか。