Quantcast
Channel: iOS and tvOS
Viewing all articles
Browse latest Browse all 10823

Allocating / Deallocating memory for UnitySendMessage()

$
0
0
I'm trying to make a Native iOS to Unity call on a game object.
On the native side I have:

Code (CSharp):
  1. char* MakeCharArray(NSString *string) {
  2.  
  3.     return strdup([string UTF8String]);
  4.  
  5. }
  6.  
  7. - (void)someNativeMethod {
  8.  
  9. UnitySendMessage("GameObject1", "TestMethod", MakeCharArray([self someNSString]));
  10.  
  11. }
  12.  
and on Unity side I have attached this code to GameObject1 in the scene:

Code (CSharp):
  1. public class Test: MonoBehaviour {
  2.     public void TestMethod (String param) {...
Allocating / Deallocating memory for UnitySendMessage()

Viewing all articles
Browse latest Browse all 10823

Trending Articles



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