I’m encountering an issue when I try to call RegisterDidChangeTagsSetCallback from my game. I get the following error in xCode: “IL2CPP does not support marshaling delegates that point to instance methods to native code.” This game is also only for iOS, so I haven’t tested it on any other platform.
I found a similar issue on Unity Answers, but the solution seemed to be to make the callback method static, which mine already was. They also seemed to have the [MonoPInvokeCallback(typeof(TagsChangedDelegate))] line above the method, which I added, but to no avail.
I’m not experienced with anything in this realm, so any help would be greatly appreciated!
C++ Code:
extern "C" {
typedef void (*TagsChangedDelegateCallback)(const char *oldTagsDate, char *oldTags[], const char *newTagsDate, char *newTags[]);
void registerDidChangeTagsSetCallback(TagsChangedDelegateCallback callback);
}
C# Code:
[DllImport("__Internal")]
private static extern void registerDidChangeTagsSetCallback(TagsChangedDelegate callback);
public delegate void TagsChangedDelegate(string oldTagsDate, string[] oldTags, string newTagsDate, string[] newTags);
[MonoPInvokeCallback(typeof(TagsChangedDelegate))]
public static void RegisterDidChangeTagsSetCallback(TagsChangedDelegate callback)
{
if (Application.platform == RuntimePlatform.IPhonePlayer)
{
registerDidChangeTagsSetCallback(callback);
}
}
Where I’m calling the code:
public void ListenForTags()
{
if (!isRegistered)
{
isRegistered = true;
LXProxSeeSDKBridge.TagsChangedDelegate tagsChangedDelegate = Something;
LXProxSeeSDKBridge.RegisterDidChangeTagsSetCallback(tagsChangedDelegate);
}
}
void Something(string oldTagsDate, string[] oldTags, string newTagsDate, string[] newTags)
{
if (newTags.Length > 0)
proxSeeTMP.text = proxSeeTMP.text + "
" + newTags[0];
}