Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

Xcode > Unity SendMessage

$
0
0
Hi, in my Unity iOS app I want to catch the memory lack to avoid the "Message from debugger: Terminated due to memory issue" and consequent crash. I followed this thread: http://answers.unity3d.com/questions/291788/is-there-a-way-to-tell-in-unity-ios-when-ondidrece.html In Unity I added a GameObject called "MemoryManagerObj"; on it I attached the following cs script: using UnityEngine; public class MemoryManager : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } void LackOfMemory(string MemMsg) { Debug.Log ("LACK OF MEMORY!!!"); } } In folder Plugins/iOS I added the following iOSMemoryController.mm: #import "UnityAppController.h" @interface iOSMemoryManager : UnityAppController {} @end @implementation iOSMemoryManager - (void)applicationDidReceiveMemoryWarning:(UIApplication*)application { printf_console("WARNING MY OWN APP CONTROLLER -> applicationDidReceiveMemoryWarning()\n"); UnityPlayer.UnitySendMessage("MemoryManagerObj", "LackOfMemory", "Message"); } @end IMPL_APP_CONTROLLER_SUBCLASS(iOSMemoryManager) I builded the Unity project and open in Xcode. Now when there is a memory issue I've this message: WARNING MY OWN APP CONTROLLER -> applicationDidReceiveMemoryWarning() SendMessage: object MemoryManagerObj not found! Message from debugger: Terminated due to memory issue though the GameObject named MemoryManagerObj exists. Where I'm wrong? Thank you!

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>