We have come out a project which can 100%(?) duplicate this issue (4/4) based on your RGB template in the tutorail for async loading. The App will crash in about 2 mins after you have started it.
Please find it under this link. And the credential is “nuitrack”. https://fs.wistron.com/?ShareToken=2122ACBD1AEAE0D229BDC516653AF5A86972B96D
With your script, RGB textures remain in memory after they’re shown. As a result, memory is filled. You can edit the script DrawColorFrame and add the deletion of a texture after it’s used:
using UnityEngine;
using UnityEngine.UI;
public class DrawColorFrame : MonoBehaviour
{
[SerializeField] RawImage background;
void Start()
{
NuitrackManager.onColorUpdate += DrawColor;
}
Texture2D bgTexture; //new line
void DrawColor(nuitrack.ColorFrame frame)
{
Destroy(bgTexture); //new line
bgTexture = frame.ToTexture2D(); //new line
background.texture = bgTexture; //modified
}
}
In this code, the texture is saved to bgTexture, shown and destroyed before it’s used again.