当Andorid或者iOS内存过低会调用此函数,注意需要Unity5.6以上的版本。用来处理内存释放 官网文档
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
class LowMemoryTrigger : MonoBehaviour
{
List<Texture2D> _textures;
private void Start()
{
_textures = new List<Texture2D>();
Application.lowMemory += OnLowMemory;
}
private void Update()
{
// allocate textures until we run out of memory
_textures.Add(new Texture2D(256, 256));
}
private void OnLowMemory()
{
// release all cached textures
_textures = new List<Texture2D>();
Resources.UnloadUnusedAssets();
}
}