I have a very simple plugin from the code from this example (https://docs.unity3d.com/Manual/NativePlugins.html). I'm updating a UI Text Field with the value from the plugin. This works as expected in the Editor but does not work when I build out a standalone application. I'm running Ubuntu 15.10.
How the library is being built:
gcc -shared PluginName.c -o PluginName.so
Here's what I've tried so far:
It seem there is very little information out there about building Unity plugins for Linux as well. An end-to-end example would be useful. Any help with this problem would be greatly appreciated.
As anticipated this ended up being a bit obscure to solve. I found someone who had run into the same problem and they were able to help me out. There is something strange going on with the way that Unity loads libraries on Linux, here is the solution.
Put your externs in their own static C# class and have a conditional for dealing with Unity library nameing
using System;
using System.Runtime.InteropServices;
public static class Native
{
// The name of the external library containing the native functions
#if UNITY_EDITOR
private const string LIBRARY_NAME = "libSimplePlugin";
#else
private const string LIBRARY_NAME = "SimplePlugin";
#endif
[DllImport(LIBRARY_NAME)] public static extern float FooPluginFunction ();
}
Call your function
Native.FooPluginFunction ();
This was verified to work in Unity 5.3.6