Too much memory used when using WebCamTexture in unity

33 Views Asked by At

If you observe the memory with a profiler while simply playing WebCamTexture, you will see that the memory is continuously increasing.

How is everyone's situation?

Is there any setting in WebCamTexture that I am missing?

Or is this just what the profiler says, and is it actually safe?

public class WebCamTest : MonoBehaviour
{
    public RawImage rimgCam;
    public Button btn0;
    public Button btn1;
    private WebCamTexture _webCamTexture;

    // Start is called before the first frame update
    void Start()
    {
        btn0.onClick.AddListener(_btn0_onClick);
        btn1.onClick.AddListener(_btn1_onClick);
        var webCamDevice = WebCamTexture.devices.First();
        _webCamTexture = new WebCamTexture(webCamDevice.name, 1280, 720, 30);
        rimgCam.material.mainTexture = _webCamTexture;
    }

    private void _btn0_onClick()
    {
        _webCamTexture.Play();
    }
    
    private void _btn1_onClick()
    {
        _webCamTexture.Stop();
    }

enter image description here

0

There are 0 best solutions below