- Home /
Objective-C native plugin implementation not working
I am trying to add a plugin i have created in Objective-C to unity. At this point my plugin is very simple. It is one of the examples in the unity manual "float FooPluginFunction () { return 5.0F; }" My plugin is written in Objective-C and is below.
WindowsController.h
#import "Foundation/Foundation.h"
#import "Cocoa/Cocoa.h"
@interface MYSDK : NSObject
@end
//#ifdef __cplusplus
//extern "C" float MySDKFooBarCFunction(){
//#endif
//
//#ifdef __cplusplus
//}
//#endif
The commented out section in code above is other method that i have tried.
WindowsController.m
#import "WindowController.h"
@implementation MYSDK
- (float)myNumber{
return 5.0f;
}
@end
#ifdef __cplusplus
extern "C" float MySDKFooBarCFunction{
return myNumber();
}
#endif
My Unity Script is written in c# and is below.
PlayThatButton.cs
using System.Runtime.InteropServices;
using UnityEngine;
public class PlayThatButton : MonoBehaviour{
#if UNITY_IPHONE && !UNITY_EDITOR
// On iOS plugins are statically linked into
// the executable, so we have to use __Internal as the
// library name.
[DllImport ("__Internal")]
#else
// Other platforms load plugins dynamically, so pass the name
// of the plugin's dynamic library.
[DllImport ("unity_playbutton_test")]
#endif
private static extern float MySDKFooBarCFunction ();
private void Awake(){
print(MySDKFooBarCFunction());
}
}
These images are here to show how i have structured everything in unity. I have added the PlayThatButton.cs file to the Main Camera object. The error i am receiving from Unity is "EntryPointNotFoundException: MySDKFooBarCFunction PlayThatButton.Awake () (at Assets/Scripts/PlayThatButton.cs:27)"
I have searched the internet finding many possible solutions, but none have worked. Clearly i am doing something wrong or forgot to implement something in addition to what i have. I am at a loss of where to go next. Any help in solving this issue would be much appreciated. Let me know if i have not included anything in the descriptions above to help you help me.
Thank you,
Your answer
Follow this Question
Related Questions
Writing unity ios plugin in Swift 1 Answer
Memory problem with UIImagePickerViewController 0 Answers
How to pass a Swift string into Unity iOS game? 0 Answers
Open Web page embedded in unity app using native UIVIEW 0 Answers
Fallback handler could not load library error on Mac OSX Build | FreeImage .dll .dylib .bundle 0 Answers