I have the following code to test unloading unused assets. Even if I put it in a coroutine, a few frames are skipped on my powerful PC. Is there no way around this?
void OnGUI() {
if (GUI.Button(new Rect(20, 20, 100, 40), "Free RAM")) {
StartCoroutine(Unload());
}
}
private IEnumerator Unload() {
Resources.UnloadUnusedAssets();
yield break;
}
I know I can call the lighter Resources.UnloadAsset if I have the object reference handy, but I don’t always.
Thanks in advance!
-Brian