简体   繁体   English

在Unity3D-Android项目中..如何获取内存警告?

[英]In a Unity3D - Android project .. how to get memory warnings?

How to be alerted of memory warnings? 如何通知内存警告? Unity3D, building to Android. Unity3D,构建到Android。

Cheers. 干杯。

据我所知,Android中没有内置功能。

You can subscribe to Application.lowMemory Documentation 您可以订阅Application.lowMemory 文档

For example, in some monoBehaviour starting your game: 例如,在开始游戏的某些行为中:

private void Start() 
{
    Application.lowMemory += ReportSystemLowMemory;
} 


private void ReportSystemLowMemory() 
{
    Debug.LogWarning("Warning: Low memory");
}
  • Be sure to don't subscribe ReportSystemLowMemory more than once. 确保不要多次订阅ReportSystemLowMemory
  • Also unsubscribing it would be a good practice, ie Application.lowMemory -= ReportSystemLowMemory when you are close your app/game. 取消订阅也将是一个好习惯, Application.lowMemory -= ReportSystemLowMemory当您关闭应用程序/游戏时, Application.lowMemory -= ReportSystemLowMemory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM