This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Runtime.InteropServices; | |
public class BridgeCSharpToObjC : MonoBehaviour | |
{ | |
#if !UNITY_EDITOR | |
[DllImport("__Internal")] | |
static extern string Test_ (); | |
#endif | |
public static string Test () | |
{ | |
#if !UNITY_EDITOR | |
return Test_ (); | |
#endif | |
return ""; | |
} | |
void Update () | |
{ | |
Debug.Log (BridgeCSharpToObjC.Test ()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
extern "C" | |
{ | |
const char* Test_() | |
{ | |
NSString *sample = @"Fugafuga"; | |
const char *str = [sample UTF8String]; | |
// 文字列の場合はmallocが必要!! | |
char* result = (char*)malloc(strlen(str)+1); | |
strcpy(result, str); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment