|
I'd like to remove textures from memory, and fall back on different shaders if I receive the onDidReceiveMemoryWarning from the iOS, but right now I do not see any documentation on how to get that message? I was wondering if anyone has done this or if there is a tool//plugin that could assist with this if Unity does not have native support for this? There are vague mentions on the forums to check UnitySendMessage in the AppController, but I have no real idea on how to do this.
(comments are locked)
|
|
I found the answer for anyone interested. In the http://AppController.mm Look for the function: This is the function that is called when your app receives a low memory warning. Next you must add a UnitySendMessage to your Unity code, so that you can receive the low memory warning message in your Unity code. So, you must modify the applicationDidReceiveMemoryWarning function by writing this code: After you add this message call to the http://AppController.mm file, in your Unity code, add a new file for the class that will be receiving the message. Mine happens to be in C#, but it can be any file type. Mine is MemoyManager.cs. Then add the code: This class now receives the message sent from the http://AppController.mm, and within your own function, mine is ReceivedMemoryWarning, handle how you deal with, free up memory within your game/project. Also, it's worth mentioning if you want to modify the http://AppController.mm and have it update automatically in xCode every time, first create a folder in your Assets folder within the Project hierarchy window named "iOS". Then drag the http://AppController.mm file into that folder with your modified code, and Unity will automatically update your changes when it builds to xCode. I hope that helps for everyone who is looking to do this, whether you're a programmer or not. Great question and superb self-answer. This should be converted to a documentation page.
May 01 at 05:54 PM
DannyB
I found out more about iOS SDK to Unity communication through your answer than through the last 3-4 weeks of reading Unity's documentation and searching elsewhere online. Bravo and thank you.
May 03 at 11:45 PM
hyliandanny
(comments are locked)
|
