スクリプトからメモリ解放する方法を自分用にメモ。
[ 方法 ]
「 System.GC.Collect(); Resources.UnloadUnusedAssets();」でメモリ解放できます。
[ 使用例 ]
下記はLキーを押すとメモリ解放するスクリプトです。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScriptTest : MonoBehaviour { private void Update() { if(Input.GetKeyDown(KeyCode.L)) { System.GC.Collect(); Resources.UnloadUnusedAssets(); } } }