Created
August 31, 2017 05:17
-
-
Save baobao/fa835acbd48c33fe8a64f1af302a3431 to your computer and use it in GitHub Desktop.
Unityネイティブプラグイン文字列やり取りの失敗例
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]; | |
return str; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment